Skip to content

Commit cd21a41

Browse files
committed
refactored ECJJava15IRTests to be parameterized
1 parent 90350c7 commit cd21a41

File tree

3 files changed

+43
-233
lines changed

3 files changed

+43
-233
lines changed

cast/java/ecj/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies {
2525
project(
2626
mapOf("path" to ":cast:java:test:data", "configuration" to "testJavaSourceDirectory")))
2727
testImplementation(libs.junit.jupiter.api)
28+
testImplementation(libs.junit.jupiter.params)
2829
testImplementation(testFixtures(projects.cast.java))
2930
}
3031

cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava15IRTest.java

+33-233
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import java.io.IOException;
1515
import java.util.Collection;
1616
import java.util.List;
17-
import org.junit.jupiter.api.Test;
17+
import java.util.stream.Stream;
18+
import org.junit.jupiter.params.ParameterizedTest;
19+
import org.junit.jupiter.params.provider.MethodSource;
1820

1921
public class ECJJava15IRTest extends IRTests {
2022

@@ -39,241 +41,39 @@ protected Iterable<Entrypoint> makeDefaultEntrypoints(IClassHierarchy cha) {
3941
return engine;
4042
}
4143

42-
@Test
43-
public void testVarargsOverriding()
44+
static Stream<String> java15IRTestNames() {
45+
return Stream.of(
46+
"AnonGeneNullarySimple",
47+
"AnonymousGenerics",
48+
"Annotations",
49+
"BasicsGenerics",
50+
"Cocovariant",
51+
"CustomGenericsAndFields",
52+
"EnumSwitch",
53+
"ExplicitBoxingTest",
54+
"GenericArrays",
55+
"GenericMemberClasses",
56+
"GenericSuperSink",
57+
"MoreOverriddenGenerics",
58+
"NotSoSimpleEnums",
59+
"OverridesOnePointFour",
60+
"SimpleEnums",
61+
"SimpleEnums2",
62+
"TypeInferencePrimAndStringOp",
63+
"Varargs",
64+
"VarargsCovariant",
65+
"VarargsOverriding",
66+
"Wildcards");
67+
}
68+
69+
@ParameterizedTest
70+
@MethodSource("java15IRTestNames")
71+
public void runJava15IRTests(String java15IRTestName)
4472
throws IllegalArgumentException, CancelException, IOException {
4573
runTest(
46-
singlePkgTestSrc("javaonepointfive"),
74+
singlePkgTestSrc("javaonepointfive", java15IRTestName),
4775
rtJar,
48-
simplePkgTestEntryPoint("javaonepointfive"),
49-
emptyList,
50-
true,
51-
null);
52-
}
53-
54-
@Test
55-
public void testEnumSwitch() throws IllegalArgumentException, CancelException, IOException {
56-
runTest(
57-
singlePkgTestSrc("javaonepointfive"),
58-
rtJar,
59-
simplePkgTestEntryPoint("javaonepointfive"),
60-
emptyList,
61-
true,
62-
null);
63-
}
64-
65-
@Test
66-
public void testOverridesOnePointFour()
67-
throws IllegalArgumentException, CancelException, IOException {
68-
runTest(
69-
singlePkgTestSrc("javaonepointfive"),
70-
rtJar,
71-
simplePkgTestEntryPoint("javaonepointfive"),
72-
emptyList,
73-
true,
74-
null);
75-
}
76-
77-
@Test
78-
public void testVarargsCovariant() throws IllegalArgumentException, CancelException, IOException {
79-
runTest(
80-
singlePkgTestSrc("javaonepointfive"),
81-
rtJar,
82-
simplePkgTestEntryPoint("javaonepointfive"),
83-
emptyList,
84-
true,
85-
null);
86-
}
87-
88-
@Test
89-
public void testSimpleEnums() throws IllegalArgumentException, CancelException, IOException {
90-
runTest(
91-
singlePkgTestSrc("javaonepointfive"),
92-
rtJar,
93-
simplePkgTestEntryPoint("javaonepointfive"),
94-
emptyList,
95-
true,
96-
null);
97-
}
98-
99-
@Test
100-
public void testGenericSuperSink() throws IllegalArgumentException, CancelException, IOException {
101-
runTest(
102-
singlePkgTestSrc("javaonepointfive"),
103-
rtJar,
104-
simplePkgTestEntryPoint("javaonepointfive"),
105-
emptyList,
106-
true,
107-
null);
108-
}
109-
110-
@Test
111-
public void testAnonGeneNullarySimple()
112-
throws IllegalArgumentException, CancelException, IOException {
113-
runTest(
114-
singlePkgTestSrc("javaonepointfive"),
115-
rtJar,
116-
simplePkgTestEntryPoint("javaonepointfive"),
117-
emptyList,
118-
true,
119-
null);
120-
}
121-
122-
@Test
123-
public void testAnonymousGenerics()
124-
throws IllegalArgumentException, CancelException, IOException {
125-
runTest(
126-
singlePkgTestSrc("javaonepointfive"),
127-
rtJar,
128-
simplePkgTestEntryPoint("javaonepointfive"),
129-
emptyList,
130-
true,
131-
null);
132-
}
133-
134-
@Test
135-
public void testNotSoSimpleEnums() throws IllegalArgumentException, CancelException, IOException {
136-
runTest(
137-
singlePkgTestSrc("javaonepointfive"),
138-
rtJar,
139-
simplePkgTestEntryPoint("javaonepointfive"),
140-
emptyList,
141-
true,
142-
null);
143-
}
144-
145-
@Test
146-
public void testVarargs() throws IllegalArgumentException, CancelException, IOException {
147-
runTest(
148-
singlePkgTestSrc("javaonepointfive"),
149-
rtJar,
150-
simplePkgTestEntryPoint("javaonepointfive"),
151-
emptyList,
152-
true,
153-
null);
154-
}
155-
156-
@Test
157-
public void testGenericArrays() throws IllegalArgumentException, CancelException, IOException {
158-
runTest(
159-
singlePkgTestSrc("javaonepointfive"),
160-
rtJar,
161-
simplePkgTestEntryPoint("javaonepointfive"),
162-
emptyList,
163-
true,
164-
null);
165-
}
166-
167-
@Test
168-
public void testAnnotations() throws IllegalArgumentException, CancelException, IOException {
169-
runTest(
170-
singlePkgTestSrc("javaonepointfive"),
171-
rtJar,
172-
simplePkgTestEntryPoint("javaonepointfive"),
173-
emptyList,
174-
true,
175-
null);
176-
}
177-
178-
@Test
179-
public void testCocovariant() throws IllegalArgumentException, CancelException, IOException {
180-
runTest(
181-
singlePkgTestSrc("javaonepointfive"),
182-
rtJar,
183-
simplePkgTestEntryPoint("javaonepointfive"),
184-
emptyList,
185-
true,
186-
null);
187-
}
188-
189-
@Test
190-
public void testExplicitBoxingTest()
191-
throws IllegalArgumentException, CancelException, IOException {
192-
runTest(
193-
singlePkgTestSrc("javaonepointfive"),
194-
rtJar,
195-
simplePkgTestEntryPoint("javaonepointfive"),
196-
emptyList,
197-
true,
198-
null);
199-
}
200-
201-
@Test
202-
public void testWildcards() throws IllegalArgumentException, CancelException, IOException {
203-
runTest(
204-
singlePkgTestSrc("javaonepointfive"),
205-
rtJar,
206-
simplePkgTestEntryPoint("javaonepointfive"),
207-
emptyList,
208-
true,
209-
null);
210-
}
211-
212-
@Test
213-
public void testBasicsGenerics() throws IllegalArgumentException, CancelException, IOException {
214-
runTest(
215-
singlePkgTestSrc("javaonepointfive"),
216-
rtJar,
217-
simplePkgTestEntryPoint("javaonepointfive"),
218-
emptyList,
219-
true,
220-
null);
221-
}
222-
223-
@Test
224-
public void testCustomGenericsAndFields()
225-
throws IllegalArgumentException, CancelException, IOException {
226-
runTest(
227-
singlePkgTestSrc("javaonepointfive"),
228-
rtJar,
229-
simplePkgTestEntryPoint("javaonepointfive"),
230-
emptyList,
231-
true,
232-
null);
233-
}
234-
235-
@Test
236-
public void testTypeInferencePrimAndStringOp()
237-
throws IllegalArgumentException, CancelException, IOException {
238-
runTest(
239-
singlePkgTestSrc("javaonepointfive"),
240-
rtJar,
241-
simplePkgTestEntryPoint("javaonepointfive"),
242-
emptyList,
243-
true,
244-
null);
245-
}
246-
247-
@Test
248-
public void testSimpleEnums2() throws IllegalArgumentException, CancelException, IOException {
249-
runTest(
250-
singlePkgTestSrc("javaonepointfive"),
251-
rtJar,
252-
simplePkgTestEntryPoint("javaonepointfive"),
253-
emptyList,
254-
true,
255-
null);
256-
}
257-
258-
@Test
259-
public void testGenericMemberClasses()
260-
throws IllegalArgumentException, CancelException, IOException {
261-
runTest(
262-
singlePkgTestSrc("javaonepointfive"),
263-
rtJar,
264-
simplePkgTestEntryPoint("javaonepointfive"),
265-
emptyList,
266-
true,
267-
null);
268-
}
269-
270-
@Test
271-
public void testMoreOverriddenGenerics()
272-
throws IllegalArgumentException, CancelException, IOException {
273-
runTest(
274-
singlePkgTestSrc("javaonepointfive"),
275-
rtJar,
276-
simplePkgTestEntryPoint("javaonepointfive"),
76+
simplePkgTestEntryPoint("javaonepointfive", java15IRTestName),
27777
emptyList,
27878
true,
27979
null);

cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java

+9
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ protected Collection<String> singlePkgTestSrc(String pkgName) {
354354
getTestSrcPath() + File.separator + singleJavaPkgInputForTest(pkgName));
355355
}
356356

357+
protected Collection<String> singlePkgTestSrc(String pkgName, String testName) {
358+
return Collections.singletonList(
359+
getTestSrcPath() + File.separator + pkgName + File.separator + testName + ".java");
360+
}
361+
357362
protected String getTestName() {
358363
StackTraceElement stack[] = new Throwable().getStackTrace();
359364
for (int i = 0; i <= stack.length; i++) {
@@ -373,6 +378,10 @@ protected String[] simplePkgTestEntryPoint(String pkgName) {
373378
return new String[] {"L" + pkgName + "/" + getTestName().substring(4)};
374379
}
375380

381+
protected String[] simplePkgTestEntryPoint(String pkgName, String testName) {
382+
return new String[] {"L" + pkgName + "/" + testName};
383+
}
384+
376385
protected abstract AbstractAnalysisEngine<InstanceKey, CallGraphBuilder<InstanceKey>, ?>
377386
getAnalysisEngine(
378387
String[] mainClassDescriptors, Collection<String> sources, List<String> libs);

0 commit comments

Comments
 (0)