commented tests for use interface where possible refactoring

This commit is contained in:
Anna Kozlova
2012-06-01 21:40:09 +04:00
parent b839853c4a
commit 472d16982d
9 changed files with 148 additions and 0 deletions
@@ -0,0 +1,16 @@
interface Int {
Int f();
}
class Impl implements Int {
void foo(){}
Impl f() {return this;}
}
class Usage {
void fk(Impl l, Impl ll){
l.f().foo();
final Impl f = ll.f();
f.foo();
}
}
@@ -0,0 +1,16 @@
interface Int {
Int f();
}
class Impl implements Int {
void foo(){}
Impl f() {return this;}
}
class Usage {
void fk(Impl l, Impl ll){
l.f().foo();
final Impl f = ll.f();
f.foo();
}
}
@@ -0,0 +1,14 @@
import java.util.*;
interface Int {}
class Impl implements Int {
void foo(){}
}
class Usage {
void f(List<Impl> l){
for (Impl aImpl : l) {
aImpl.foo();
}
l.get(0).foo();
}
}
@@ -0,0 +1,14 @@
import java.util.*;
interface Int {}
class Impl implements Int {
void foo(){}
}
class Usage {
void f(List<Impl> l){
for (Impl aImpl : l) {
aImpl.foo();
}
l.get(0).foo();
}
}
@@ -0,0 +1,25 @@
import java.util.*;
interface Int {
}
class Impl implements Int {
void foo() {
}
}
class Usage {
void f() {
List<Impl> l = new ArrayList<Impl>();
l.get(0).foo();
List<Int> l1 = new ArrayList<Int>();
Int i = l1.get(0);
List<Impl> l2 = new ArrayList<Impl>();
Impl i2 = l2.get(0);
i2.foo();
}
}
@@ -0,0 +1,25 @@
import java.util.*;
interface Int {
}
class Impl implements Int {
void foo() {
}
}
class Usage {
void f() {
List<Impl> l = new ArrayList<Impl>();
l.get(0).foo();
List<Impl> l1 = new ArrayList<Impl>();
Impl i = l1.get(0);
List<Impl> l2 = new ArrayList<Impl>();
Impl i2 = l2.get(0);
i2.foo();
}
}
@@ -0,0 +1,11 @@
import java.util.*;
interface Int {}
class Impl implements Int {
}
class Usage {
void f(List<Int> l){}
void bar() {
f(Collections.<Int>emptyList());
}
}
@@ -0,0 +1,11 @@
import java.util.*;
interface Int {}
class Impl implements Int {
}
class Usage {
void f(List<Impl> l){}
void bar() {
f(Collections.<Impl>emptyList());
}
}