Skip to content

Commit c53cb29

Browse files
author
svorenova
committed
Adding and updating unit tests
1 parent a1e9d00 commit c53cb29

39 files changed

+1123
-34
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Helper classes
2+
class Wrapper<T> {
3+
public T field;
4+
}
5+
6+
class IntWrapper {
7+
public int i;
8+
}
9+
10+
class TwoWrapper<K, V> {
11+
public K first;
12+
public V second;
13+
}
14+
15+
interface InterfaceWrapper<T> {
16+
public T method(T t);
17+
}
18+
19+
// A class extending a generic class instantiated with a standard library class
20+
class SuperclassInst extends Wrapper<Integer> {
21+
public void foo() {
22+
this.field = 5;
23+
}
24+
}
25+
26+
// A class extending a generic class instantiated with a user-defined class
27+
class SuperclassInst2 extends Wrapper<IntWrapper> {
28+
public void foo() {
29+
this.field.i = 5;
30+
}
31+
}
32+
33+
// A class extending an instantiated nested generic class
34+
class SuperclassInst3 extends Wrapper<Wrapper<IntWrapper>> {
35+
public void foo() {
36+
this.field.field.i = 5;
37+
}
38+
}
39+
40+
// A generic class extending a generic class (must be with the same parameter)
41+
class SuperclassUninst<U> extends Wrapper<U> {
42+
public void foo(U value) {
43+
this.field = value;
44+
}
45+
}
46+
class SuperclassUninstTest
47+
{
48+
SuperclassUninst<Integer> f;
49+
public void foo() {
50+
f.foo(new Integer(1));
51+
}
52+
}
53+
54+
55+
// A generic class extending a generic class with both instantiated and
56+
// uninstantiated parameters
57+
class SuperclassMixed<U> extends TwoWrapper<U,IntWrapper> {
58+
public void foo(U value) {
59+
this.first = value;
60+
this.second.i = 5;
61+
}
62+
}
63+
class SuperclassMixedTest
64+
{
65+
SuperclassMixed<Boolean> f;
66+
public void foo() {
67+
f.foo(true);
68+
}
69+
}
70+
71+
// Inner classes (generic or not) extending generic classes
72+
class SuperclassInnerInst {
73+
class Inner extends Wrapper<Integer> {
74+
public void foo() {
75+
this.field = 5;
76+
}
77+
}
78+
public Inner inner;
79+
80+
class InnerGen<T> extends Wrapper<T> {
81+
public void foo(T value) {
82+
this.field = value;
83+
}
84+
}
85+
public InnerGen<Boolean> inner_gen;
86+
87+
public void foo() {
88+
inner.foo();
89+
inner_gen.foo(true);
90+
}
91+
}
92+
93+
// Implicitly generic inner classes (generic or not) extending generic classes
94+
class SuperclassInnerUninst<U> {
95+
class Inner extends Wrapper<U> {
96+
public void foo(U value) {
97+
this.field = value;
98+
}
99+
}
100+
public Inner inner;
101+
102+
class InnerGen<T> extends TwoWrapper<U,T> {
103+
public void foo(U uvalue, T tvalue) {
104+
this.first = uvalue;
105+
this.second = tvalue;
106+
}
107+
}
108+
public InnerGen<Boolean> inner_gen;
109+
110+
class InnerThree extends Inner {
111+
}
112+
public InnerThree inner_three;
113+
}
114+
class SuperclassInnerUninstTest
115+
{
116+
SuperclassInnerUninst<IntWrapper> f;
117+
public void foo() {
118+
IntWrapper x = new IntWrapper();
119+
f.inner.foo(x);
120+
f.inner_gen.foo(x,true);
121+
f.inner_three.foo(x);
122+
}
123+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)