Skip to content

Commit 5668e84

Browse files
committed
refactored ECJJava17IRTests to be parameterized
1 parent cd21a41 commit 5668e84

File tree

1 file changed

+22
-64
lines changed

1 file changed

+22
-64
lines changed

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

+22-64
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
import java.util.Collections;
3535
import java.util.List;
3636
import java.util.Set;
37-
import org.junit.jupiter.api.Test;
37+
import java.util.stream.Stream;
38+
import org.junit.jupiter.params.ParameterizedTest;
39+
import org.junit.jupiter.params.provider.Arguments;
40+
import org.junit.jupiter.params.provider.MethodSource;
3841

3942
public class ECJJava17IRTest extends IRTests {
4043

@@ -61,7 +64,7 @@ protected Iterable<Entrypoint> makeDefaultEntrypoints(IClassHierarchy cha) {
6164
return engine;
6265
}
6366

64-
private final IRAssertion checkBinaryLiterals =
67+
private static final IRAssertion checkBinaryLiterals =
6568
new IRAssertion() {
6669
private final TypeReference testClass =
6770
TypeReference.findOrCreate(
@@ -107,18 +110,7 @@ public void check(CallGraph cg) {
107110
}
108111
};
109112

110-
@Test
111-
public void testBinaryLiterals() throws IllegalArgumentException, CancelException, IOException {
112-
runTest(
113-
singlePkgTestSrc("javaonepointseven"),
114-
rtJar,
115-
simplePkgTestEntryPoint("javaonepointseven"),
116-
Collections.singletonList(checkBinaryLiterals),
117-
true,
118-
null);
119-
}
120-
121-
private final IRAssertion checkCatchMultipleExceptionTypes =
113+
private static final IRAssertion checkCatchMultipleExceptionTypes =
122114
new IRAssertion() {
123115

124116
private final TypeReference testClass =
@@ -161,18 +153,6 @@ public void check(CallGraph cg) {
161153
}
162154
};
163155

164-
@Test
165-
public void testCatchMultipleExceptionTypes()
166-
throws IllegalArgumentException, CancelException, IOException {
167-
runTest(
168-
singlePkgTestSrc("javaonepointseven"),
169-
rtJar,
170-
simplePkgTestEntryPoint("javaonepointseven"),
171-
Collections.singletonList(checkCatchMultipleExceptionTypes),
172-
true,
173-
null);
174-
}
175-
176156
private static final List<IRAssertion> SiSAssertions =
177157
Collections.singletonList(
178158
new InstructionOperandAssertion(
@@ -183,49 +163,27 @@ public void testCatchMultipleExceptionTypes()
183163
1,
184164
new int[] {9, 58, 9, 67}));
185165

186-
@Test
187-
public void testStringsInSwitch() throws IllegalArgumentException, CancelException, IOException {
188-
runTest(
189-
singlePkgTestSrc("javaonepointseven"),
190-
rtJar,
191-
simplePkgTestEntryPoint("javaonepointseven"),
192-
SiSAssertions,
193-
true,
194-
null);
195-
}
196-
197-
@Test
198-
public void testTryWithResourcesStatement()
199-
throws IllegalArgumentException, CancelException, IOException {
200-
runTest(
201-
singlePkgTestSrc("javaonepointseven"),
202-
rtJar,
203-
simplePkgTestEntryPoint("javaonepointseven"),
204-
emptyList,
205-
true,
206-
null);
207-
}
208-
209-
@Test
210-
public void testTypeInferenceforGenericInstanceCreation()
211-
throws IllegalArgumentException, CancelException, IOException {
212-
runTest(
213-
singlePkgTestSrc("javaonepointseven"),
214-
rtJar,
215-
simplePkgTestEntryPoint("javaonepointseven"),
216-
emptyList,
217-
true,
218-
null);
166+
static Stream<Arguments> java17IRTestNames() {
167+
return Stream.of(
168+
Arguments.of("BinaryLiterals", Collections.singletonList(checkBinaryLiterals)),
169+
Arguments.of(
170+
"CatchMultipleExceptionTypes",
171+
Collections.singletonList(checkCatchMultipleExceptionTypes)),
172+
Arguments.of("StringsInSwitch", SiSAssertions),
173+
Arguments.of("TypeInferenceforGenericInstanceCreation", emptyList),
174+
Arguments.of("TryWithResourcesStatement", emptyList),
175+
Arguments.of("UnderscoresInNumericLiterals", emptyList));
219176
}
220177

221-
@Test
222-
public void testUnderscoresInNumericLiterals()
178+
@ParameterizedTest
179+
@MethodSource("java17IRTestNames")
180+
public void runJava17IRTests(String java17IRTestName, List<IRAssertion> ca)
223181
throws IllegalArgumentException, CancelException, IOException {
224182
runTest(
225-
singlePkgTestSrc("javaonepointseven"),
183+
singlePkgTestSrc("javaonepointseven", java17IRTestName),
226184
rtJar,
227-
simplePkgTestEntryPoint("javaonepointseven"),
228-
emptyList,
185+
simplePkgTestEntryPoint("javaonepointseven", java17IRTestName),
186+
ca,
229187
true,
230188
null);
231189
}

0 commit comments

Comments
 (0)