Skip to content

Commit c4f3cea

Browse files
author
svorenova
committed
Add unit tests for mocked/unsupported generics
1 parent c43fd45 commit c4f3cea

13 files changed

+284
-0
lines changed

unit/goto-programs/goto_program_generics/GenericBases.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,15 @@ public void foo() {
103103
f.inner_three.foo(x);
104104
}
105105
}
106+
107+
class SuperclassUnsupported extends UnsupportedWrapper1<SuperclassUnsupported> {
108+
public void foo() {
109+
this.field = new SuperclassUnsupported();
110+
}
111+
}
112+
113+
class SuperclassMocked extends MockedWrapper<IWrapper> {
114+
public void foo() {
115+
this.field.i = 5;
116+
}
117+
}
Binary file not shown.
Binary file not shown.

unit/goto-programs/goto_program_generics/GenericFields.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,35 @@ public void foo(A<Integer> v) {
8080
}
8181
}
8282
}
83+
84+
// class that implements two generic interfaces
85+
class InterfacesImplementation implements InterfaceWrapper<IWrapper>,
86+
InterfacePairWrapper<IWrapper, IWrapper> {
87+
public IWrapper method(IWrapper t) {
88+
return t;
89+
}
90+
public IWrapper method(IWrapper t, IWrapper tt) {
91+
if (t.i>0)
92+
{
93+
return t;
94+
}
95+
else
96+
{
97+
return tt;
98+
}
99+
}
100+
}
101+
class GenericFieldUnsupported {
102+
public UnsupportedWrapper2<InterfacesImplementation> f;
103+
public void foo() {
104+
f.field.method(new IWrapper(0));
105+
f.field.method(new IWrapper(0), new IWrapper(2));
106+
}
107+
}
108+
109+
class GenericFieldMocked {
110+
public MockedWrapper<IWrapper> f;
111+
public void foo() {
112+
f.field.i = 0;
113+
}
114+
}

unit/goto-programs/goto_program_generics/GenericHelper.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,24 @@ class PairWrapper<K, V> {
2323
interface InterfaceWrapper<T> {
2424
public T method(T t);
2525
}
26+
27+
// generic interface with two parameters
28+
interface InterfacePairWrapper<K, V> {
29+
public K method(K k, V v);
30+
}
31+
32+
// generic class with unsupported signature - generic bound
33+
class UnsupportedWrapper1<T extends UnsupportedWrapper1<T>> {
34+
public T field;
35+
}
36+
37+
// generic class with unsupported signature - multiple bounds
38+
class UnsupportedWrapper2<T extends InterfaceWrapper & InterfacePairWrapper>
39+
{
40+
public T field;
41+
}
42+
43+
// generic mocked class, make sure the .class file is not available
44+
class MockedWrapper<T> {
45+
public T field;
46+
}
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)