Skip to content

Commit c43fd45

Browse files
author
svorenova
committed
Pull out common generic classes/interfaces for unit tests
1 parent d69d120 commit c43fd45

39 files changed

+65
-74
lines changed

unit/goto-programs/goto_program_generics/GenericBases.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
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-
191
// A class extending a generic class instantiated with a standard library class
202
class SuperclassInst extends Wrapper<Integer> {
213
public void foo() {
@@ -24,14 +6,14 @@ public void foo() {
246
}
257

268
// A class extending a generic class instantiated with a user-defined class
27-
class SuperclassInst2 extends Wrapper<IntWrapper> {
9+
class SuperclassInst2 extends Wrapper<IWrapper> {
2810
public void foo() {
2911
this.field.i = 5;
3012
}
3113
}
3214

3315
// A class extending an instantiated nested generic class
34-
class SuperclassInst3 extends Wrapper<Wrapper<IntWrapper>> {
16+
class SuperclassInst3 extends Wrapper<Wrapper<IWrapper>> {
3517
public void foo() {
3618
this.field.field.i = 5;
3719
}
@@ -54,7 +36,7 @@ public void foo() {
5436

5537
// A generic class extending a generic class with both instantiated and
5638
// uninstantiated parameters
57-
class SuperclassMixed<U> extends TwoWrapper<U,IntWrapper> {
39+
class SuperclassMixed<U> extends PairWrapper<U,IWrapper> {
5840
public void foo(U value) {
5941
this.first = value;
6042
this.second.i = 5;
@@ -99,7 +81,7 @@ public void foo(U value) {
9981
}
10082
public Inner inner;
10183

102-
class InnerGen<T> extends TwoWrapper<U,T> {
84+
class InnerGen<T> extends PairWrapper<U,T> {
10385
public void foo(U uvalue, T tvalue) {
10486
this.first = uvalue;
10587
this.second = tvalue;
@@ -113,9 +95,9 @@ class InnerThree extends Inner {
11395
}
11496
class SuperclassInnerUninstTest
11597
{
116-
SuperclassInnerUninst<IntWrapper> f;
98+
SuperclassInnerUninst<IWrapper> f;
11799
public void foo() {
118-
IntWrapper x = new IntWrapper();
100+
IWrapper x = new IWrapper();
119101
f.inner.foo(x);
120102
f.inner_gen.foo(x,true);
121103
f.inner_three.foo(x);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)