Repository: wala/WALA
Pull request #1485: refactor: remove getTestName from IRTests.java so tests do not rely on method name
Author: login: jkhaliqi
Created: 2025-03-06T21:05:11Z | Merged: 2025-03-22T00:09:26Z

Cleaned up `ECJJava15IRTest.java` by refactoring the tests to be parameterized to not rely on method name for running the tests. Also removed the `getTestName` from `IRTests` so the tests do not rely on that method to get the name of the test it should run. With this we pass in the name and tests can now be parameterized as well instead of relying on naming tests differently


Diff:
diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml
index 28455073c4..9cea2dbce3 100644
--- a/.github/workflows/publish-test-results.yml
+++ b/.github/workflows/publish-test-results.yml
@@ -30,3 +30,4 @@ jobs:
           event_file: artifacts/Event file/event.json
           event_name: ${{ github.event.workflow_run.event }}
           files: "artifacts/**/*.xml"
+          test_changes_limit: 500
diff --git a/cast/java/build.gradle.kts b/cast/java/build.gradle.kts
index b4c0c155a9..255796d4ea 100644
--- a/cast/java/build.gradle.kts
+++ b/cast/java/build.gradle.kts
@@ -11,6 +11,7 @@ dependencies {
   api(projects.util)
   implementation(projects.shrike)
   testFixturesApi(libs.junit.jupiter.api)
+  testFixturesApi(libs.junit.jupiter.params)
   testFixturesApi(projects.core)
   testFixturesApi(projects.util)
   testFixturesImplementation(projects.cast)
diff --git a/cast/java/ecj/build.gradle.kts b/cast/java/ecj/build.gradle.kts
index 778988f556..f6524e89ee 100644
--- a/cast/java/ecj/build.gradle.kts
+++ b/cast/java/ecj/build.gradle.kts
@@ -25,6 +25,7 @@ dependencies {
       project(
           mapOf("path" to ":cast:java:test:data", "configuration" to "testJavaSourceDirectory")))
   testImplementation(libs.junit.jupiter.api)
+  testImplementation(libs.junit.jupiter.params)
   testImplementation(testFixtures(projects.cast.java))
 }
 
diff --git a/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava15IRTest.java b/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava15IRTest.java
index 6e40ad360e..93511cbdb9 100644
--- a/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava15IRTest.java
+++ b/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava15IRTest.java
@@ -14,7 +14,9 @@
 import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
-import org.junit.jupiter.api.Test;
+import java.util.stream.Stream;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 public class ECJJava15IRTest extends IRTests {
 
@@ -39,241 +41,39 @@ protected Iterable<Entrypoint> makeDefaultEntrypoints(IClassHierarchy cha) {
     return engine;
   }
 
-  @Test
-  public void testVarargsOverriding()
+  static Stream<String> java15IRTestNames() {
+    return Stream.of(
+        "AnonGeneNullarySimple",
+        "AnonymousGenerics",
+        "Annotations",
+        "BasicsGenerics",
+        "Cocovariant",
+        "CustomGenericsAndFields",
+        "EnumSwitch",
+        "ExplicitBoxingTest",
+        "GenericArrays",
+        "GenericMemberClasses",
+        "GenericSuperSink",
+        "MoreOverriddenGenerics",
+        "NotSoSimpleEnums",
+        "OverridesOnePointFour",
+        "SimpleEnums",
+        "SimpleEnums2",
+        "TypeInferencePrimAndStringOp",
+        "Varargs",
+        "VarargsCovariant",
+        "VarargsOverriding",
+        "Wildcards");
+  }
+
+  @ParameterizedTest
+  @MethodSource("java15IRTestNames")
+  public void runJava15IRTests(String java15IRTestName)
       throws IllegalArgumentException, CancelException, IOException {
     runTest(
-        singlePkgTestSrc("javaonepointfive"),
+        singlePkgTestSrc("javaonepointfive", java15IRTestName),
         rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testEnumSwitch() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testOverridesOnePointFour()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testVarargsCovariant() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testSimpleEnums() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testGenericSuperSink() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testAnonGeneNullarySimple()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testAnonymousGenerics()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testNotSoSimpleEnums() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testVarargs() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testGenericArrays() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testAnnotations() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testCocovariant() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testExplicitBoxingTest()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testWildcards() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testBasicsGenerics() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testCustomGenericsAndFields()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testTypeInferencePrimAndStringOp()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testSimpleEnums2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testGenericMemberClasses()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testMoreOverriddenGenerics()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointfive"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointfive"),
+        simplePkgTestEntryPoint("javaonepointfive", java15IRTestName),
         emptyList,
         true,
         null);
diff --git a/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava17IRTest.java b/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava17IRTest.java
index c48fca05b8..bef9503b7f 100644
--- a/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava17IRTest.java
+++ b/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava17IRTest.java
@@ -34,7 +34,10 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-import org.junit.jupiter.api.Test;
+import java.util.stream.Stream;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 public class ECJJava17IRTest extends IRTests {
 
@@ -61,7 +64,7 @@ protected Iterable<Entrypoint> makeDefaultEntrypoints(IClassHierarchy cha) {
     return engine;
   }
 
-  private final IRAssertion checkBinaryLiterals =
+  private static final IRAssertion checkBinaryLiterals =
       new IRAssertion() {
         private final TypeReference testClass =
             TypeReference.findOrCreate(
@@ -107,18 +110,7 @@ public void check(CallGraph cg) {
         }
       };
 
-  @Test
-  public void testBinaryLiterals() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointseven"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointseven"),
-        Collections.singletonList(checkBinaryLiterals),
-        true,
-        null);
-  }
-
-  private final IRAssertion checkCatchMultipleExceptionTypes =
+  private static final IRAssertion checkCatchMultipleExceptionTypes =
       new IRAssertion() {
 
         private final TypeReference testClass =
@@ -161,18 +153,6 @@ public void check(CallGraph cg) {
         }
       };
 
-  @Test
-  public void testCatchMultipleExceptionTypes()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointseven"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointseven"),
-        Collections.singletonList(checkCatchMultipleExceptionTypes),
-        true,
-        null);
-  }
-
   private static final List<IRAssertion> SiSAssertions =
       Collections.singletonList(
           new InstructionOperandAssertion(
@@ -183,49 +163,27 @@ public void testCatchMultipleExceptionTypes()
               1,
               new int[] {9, 58, 9, 67}));
 
-  @Test
-  public void testStringsInSwitch() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointseven"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointseven"),
-        SiSAssertions,
-        true,
-        null);
-  }
-
-  @Test
-  public void testTryWithResourcesStatement()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointseven"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointseven"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testTypeInferenceforGenericInstanceCreation()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singlePkgTestSrc("javaonepointseven"),
-        rtJar,
-        simplePkgTestEntryPoint("javaonepointseven"),
-        emptyList,
-        true,
-        null);
+  static Stream<Arguments> java17IRTestNames() {
+    return Stream.of(
+        Arguments.of("BinaryLiterals", Collections.singletonList(checkBinaryLiterals)),
+        Arguments.of(
+            "CatchMultipleExceptionTypes",
+            Collections.singletonList(checkCatchMultipleExceptionTypes)),
+        Arguments.of("StringsInSwitch", SiSAssertions),
+        Arguments.of("TypeInferenceforGenericInstanceCreation", emptyList),
+        Arguments.of("TryWithResourcesStatement", emptyList),
+        Arguments.of("UnderscoresInNumericLiterals", emptyList));
   }
 
-  @Test
-  public void testUnderscoresInNumericLiterals()
+  @ParameterizedTest
+  @MethodSource("java17IRTestNames")
+  public void runJava17IRTests(String java17IRTestName, List<IRAssertion> ca)
       throws IllegalArgumentException, CancelException, IOException {
     runTest(
-        singlePkgTestSrc("javaonepointseven"),
+        singlePkgTestSrc("javaonepointseven", java17IRTestName),
         rtJar,
-        simplePkgTestEntryPoint("javaonepointseven"),
-        emptyList,
+        simplePkgTestEntryPoint("javaonepointseven", java17IRTestName),
+        ca,
         true,
         null);
   }
diff --git a/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJTestComments.java b/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJTestComments.java
index f4c555d5ca..eefa425ced 100644
--- a/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJTestComments.java
+++ b/cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJTestComments.java
@@ -59,8 +59,7 @@ protected Iterable<Entrypoint> makeDefaultEntrypoints(IClassHierarchy cha) {
 
   @Test
   public void testComments() throws IllegalArgumentException, CancelException, IOException {
-    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> result =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
+    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> result = runTest("Comments");
     for (CGNode node : result.fst.getNodes(testMethod)) {
       if (node.getMethod() instanceof AstMethod) {
         AstMethod m = (AstMethod) node.getMethod();
diff --git a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java
index bc6287a5ee..4bef3285a1 100644
--- a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java
+++ b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java
@@ -340,43 +340,33 @@ public void check(CallGraph cg) {
     }
   }
 
-  protected Collection<String> singleTestSrc() {
-    return Collections.singletonList(getTestSrcPath() + File.separator + singleJavaInputForTest());
+  protected Collection<String> singleTestSrc(String testName) {
+    return Collections.singletonList(getTestSrcPath() + File.separator + testName + ".java");
   }
 
-  protected Collection<String> singleTestSrc(final String folder) {
+  protected Collection<String> singlePkgTestSrc(String pkgName, String testName) {
     return Collections.singletonList(
-        getTestSrcPath() + File.separator + folder + File.separator + singleJavaInputForTest());
+        getTestSrcPath() + File.separator + pkgName + File.separator + testName + ".java");
   }
 
-  protected Collection<String> singlePkgTestSrc(String pkgName) {
-    return Collections.singletonList(
-        getTestSrcPath() + File.separator + singleJavaPkgInputForTest(pkgName));
-  }
-
-  protected String getTestName() {
-    StackTraceElement stack[] = new Throwable().getStackTrace();
-    for (int i = 0; i <= stack.length; i++) {
-      if (stack[i].getMethodName().startsWith("test")) {
-        return stack[i].getMethodName();
-      }
-    }
-
-    throw new Error("test method not found");
+  protected String[] simpleTestEntryPoint(String testName) {
+    return new String[] {'L' + testName};
   }
 
-  protected String[] simpleTestEntryPoint() {
-    return new String[] {'L' + getTestName().substring(4)};
-  }
-
-  protected String[] simplePkgTestEntryPoint(String pkgName) {
-    return new String[] {"L" + pkgName + "/" + getTestName().substring(4)};
+  protected String[] simplePkgTestEntryPoint(String pkgName, String testName) {
+    return new String[] {"L" + pkgName + "/" + testName};
   }
 
   protected abstract AbstractAnalysisEngine<InstanceKey, CallGraphBuilder<InstanceKey>, ?>
       getAnalysisEngine(
           String[] mainClassDescriptors, Collection<String> sources, List<String> libs);
 
+  public Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> runTest(String testName)
+      throws CancelException, IOException {
+    return runTest(
+        singleTestSrc(testName), rtJar, simpleTestEntryPoint(testName), emptyList, true, null);
+  }
+
   public Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> runTest(
       Collection<String> sources,
       List<String> libs,
@@ -524,15 +514,11 @@ protected String getTestSrcPath() {
     return testSrcPath;
   }
 
-  protected String singleJavaInputForTest() {
-    return getTestName().substring(4) + ".java";
-  }
-
-  protected String singleInputForTest() {
-    return getTestName().substring(4);
+  protected static String singleInputForTest(String testName) {
+    return testName;
   }
 
-  protected String singleJavaPkgInputForTest(String pkgName) {
-    return pkgName + File.separator + getTestName().substring(4) + ".java";
+  protected String singleJavaPkgInputForTest(String pkgName, String testName) {
+    return pkgName + File.separator + testName + ".java";
   }
 }
diff --git a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue666Test.java b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue666Test.java
index 604ee84596..03f5a97882 100644
--- a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue666Test.java
+++ b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue666Test.java
@@ -22,7 +22,13 @@ public Issue666Test(String projectName) {
   @Test
   public void testPeekErrorCase() throws CancelException, IOException {
     Pair<CallGraph, ?> result =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
+        runTest(
+            singleTestSrc("PeekErrorCase"),
+            rtJar,
+            simpleTestEntryPoint("PeekErrorCase"),
+            emptyList,
+            true,
+            null);
 
     assert result != null;
 
diff --git a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue667Test.java b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue667Test.java
index dc2147da3d..fc009d3a4d 100644
--- a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue667Test.java
+++ b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/Issue667Test.java
@@ -24,7 +24,13 @@ public Issue667Test(String projectName) {
   @Test
   public void testDominanceFrontierCase() throws CancelException, IOException {
     Pair<CallGraph, ?> result =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
+        runTest(
+            singleTestSrc("DominanceFrontierCase"),
+            rtJar,
+            simpleTestEntryPoint("DominanceFrontierCase"),
+            emptyList,
+            true,
+            null);
 
     MethodReference cm =
         MethodReference.findOrCreate(
diff --git a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JLexTest.java b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JLexTest.java
index b329d2a559..b378137400 100644
--- a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JLexTest.java
+++ b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JLexTest.java
@@ -20,18 +20,12 @@ public JLexTest() {
     super(null);
   }
 
-  @Override
   protected String singleJavaInputForTest() {
     return "JLex";
   }
 
   @Test
   public void testJLex() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, new String[] {"LJLex/Main"}, emptyList, false, null);
-  }
-
-  @Override
-  protected String singleJavaPkgInputForTest(String pkgName) {
-    return "";
+    runTest(singleTestSrc("JLex"), rtJar, new String[] {"LJLex/Main"}, emptyList, false, null);
   }
 }
diff --git a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
index 5ea348343c..451aafdc9c 100644
--- a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
+++ b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
@@ -61,14 +61,17 @@
 import com.ibm.wala.util.io.TemporaryFile;
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Stream;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 public abstract class JavaIRTests extends IRTests {
 
@@ -80,371 +83,404 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
+  static List<? extends IRAssertion> callAssertionForInterfaceTest1 =
+      Arrays.asList(
+          cg -> {
+            final String typeStr = "IFoo";
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testInterfaceTest1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Arrays.asList(
-            cg -> {
-              final String typeStr = "IFoo";
+            assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
+          },
+          cg -> {
+            final String typeStr = "FooIT1";
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
-            },
-            cg -> {
-              final String typeStr = "FooIT1";
+            final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            assertEquals(interfaces.size(), 1, "Expected one single interface.");
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            assertTrue(
+                interfaces.contains(
+                    cg.getClassHierarchy()
+                        .lookupClass(
+                            findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
+                "Expected Foo to implement IFoo");
+          });
 
-              final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
+  static List<? extends IRAssertion> callAssertionForInheritance1 =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = "Derived";
 
-              assertEquals(interfaces.size(), 1, "Expected one single interface.");
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              assertTrue(
-                  interfaces.contains(
-                      cg.getClassHierarchy()
-                          .lookupClass(
-                              findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
-                  "Expected Foo to implement IFoo");
-            }),
-        true,
-        null);
-  }
+            final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(derivedClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testInheritance1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = "Derived";
+            final TypeReference baseType =
+                findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
+            final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            assertEquals(
+                derivedClass.getSuperclass(),
+                baseClass,
+                "Expected 'Base' to be the superclass of 'Derived'");
 
-              final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(derivedClass, "Could not find class " + typeStr);
+            Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
 
-              final TypeReference baseType =
-                  findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
-              final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
+            assertTrue(
+                subclasses.contains(derivedClass) && subclasses.contains(baseClass),
+                "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
+          });
 
-              assertEquals(
-                  derivedClass.getSuperclass(),
-                  baseClass,
-                  "Expected 'Base' to be the superclass of 'Derived'");
-
-              Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
-
-              assertTrue(
-                  subclasses.contains(derivedClass) && subclasses.contains(baseClass),
-                  "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> callAssertionForArrayLiteral1 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[2];
+            assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
+            assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
+          });
+
+  static List<? extends IRAssertion> callAssertionForQualifiedStatic =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[4];
+
+            assertTrue(
+                s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
+                "Did not find a getstatic instruction.");
+            final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
+            assertEquals(field.getName().toString(), "value", "Expected a getstatic for 'value'.");
+            assertEquals(
+                field.getDeclaringClass().getName().toString(),
+                "LFooQ",
+                "Expected a getstatic for 'value'.");
+          });
 
-  @Test
-  public void testArray1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            /*
-             * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
-             * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
-             */
-            new IRAssertion() {
+  static List<? extends IRAssertion> callAssertionForArrayLiteral2 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+
+            final SSAInstruction[] instructions = node.getIR().getInstructions();
+            // test 1
+            {
+              SSAInstruction s1 = instructions[2];
+              if (s1 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 3rd to be a new array instruction.");
+              }
+            }
+            // test 2
+            {
+              SSAInstruction s2 = instructions[3];
+              if (s2 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 4th to be a new array instruction.");
+              }
+            }
+            // test 3: the last 4 instructions are of the form y[i] = i+1;
+            {
+              final SymbolTable symbolTable = node.getIR().getSymbolTable();
+              for (int i = 4; i <= 7; i++) {
+                assertInstanceOf(
+                    SSAArrayStoreInstruction.class, instructions[i], "Expected only array stores.");
+
+                SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
+
+                assertEquals(
+                    node.getIR().getLocalNames(i, as.getArrayRef())[0],
+                    "y",
+                    "Expected an array store to 'y'.");
+
+                final Integer valueOfArrayIndex =
+                    ((Integer) symbolTable.getConstantValue(as.getIndex()));
+                final Integer valueAssigned = (Integer) symbolTable.getConstantValue(as.getValue());
+
+                assertEquals(
+                    valueAssigned.intValue(),
+                    valueOfArrayIndex + 1,
+                    "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
+              }
+            }
+          });
+
+  static List<EdgeAssertions> edgeAssertionses =
+      Arrays.asList(
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
+  static List<? extends IRAssertion> callAssertionForArray1 =
+      Collections.singletonList(
+          /*
+           * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
+           * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
+           */
+          new IRAssertion() {
 
-              @Override
-              public void check(CallGraph cg) {
+            @Override
+            public void check(CallGraph cg) {
 
-                MethodReference mref =
-                    descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
+              MethodReference mref =
+                  descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
 
-                int count = 0;
-                CGNode node = cg.getNodes(mref).iterator().next();
-                for (SSAInstruction s : node.getIR().getInstructions()) {
-                  if (isArrayInstruction(s)) {
-                    count++;
-                  }
+              int count = 0;
+              CGNode node = cg.getNodes(mref).iterator().next();
+              for (SSAInstruction s : node.getIR().getInstructions()) {
+                if (isArrayInstruction(s)) {
+                  count++;
                 }
-
-                assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
               }
 
-              private boolean isArrayInstruction(SSAInstruction s) {
-                return s instanceof SSAArrayReferenceInstruction
-                    || s instanceof SSAArrayLengthInstruction;
-              }
-            }),
-        true,
-        null);
-  }
+              assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+            }
 
-  @Test
-  public void testArrayLiteral1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            private boolean isArrayInstruction(SSAInstruction s) {
+              return s instanceof SSAArrayReferenceInstruction
+                  || s instanceof SSAArrayLengthInstruction;
+            }
+          });
+
+  static List<? extends IRAssertion> callAssertionForsimple1 =
+      Arrays.asList(
+          new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
+          new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
+          EdgeAssertions.make(
+              "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
+          EdgeAssertions.make(
+              "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
+
+  static List<? extends IRAssertion> callAssertionForTwoClasses =
+      List.of(
+          cg -> {
+            final String typeStr = singleInputForTest("TwoClasses");
+
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[2];
-              assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
-              assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
-            }),
-        true,
-        null);
-  }
+            /*
+            assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
 
-  @Test
-  public void testArrayLiteral2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
+              assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
+                  .equals(typeStr)
+                  || cls.getName().getClassName().toString().equals("Bar"));
+            }
+            */
+          });
+  static List<? extends IRAssertion> callAssertionForStaticNesting =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("StaticNesting") + "$WhatsIt";
 
-              CGNode node = cg.getNodes(mref).iterator().next();
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final SSAInstruction[] instructions = node.getIR().getInstructions();
-              // test 1
-              {
-                SSAInstruction s1 = instructions[2];
-                if (s1 instanceof SSANewInstruction) {
-                  assertTrue(
-                      ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
-                } else {
-                  fail("Expected 3rd to be a new array instruction.");
-                }
-              }
-              // test 2
-              {
-                SSAInstruction s2 = instructions[3];
-                if (s2 instanceof SSANewInstruction) {
-                  assertTrue(
-                      ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
-                } else {
-                  fail("Expected 4th to be a new array instruction.");
-                }
-              }
-              // test 3: the last 4 instructions are of the form y[i] = i+1;
-              {
-                final SymbolTable symbolTable = node.getIR().getSymbolTable();
-                for (int i = 4; i <= 7; i++) {
-                  assertInstanceOf(
-                      SSAArrayStoreInstruction.class,
-                      instructions[i],
-                      "Expected only array stores.");
-
-                  SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
-
-                  assertEquals(
-                      node.getIR().getLocalNames(i, as.getArrayRef())[0],
-                      "y",
-                      "Expected an array store to 'y'.");
-
-                  final Integer valueOfArrayIndex =
-                      ((Integer) symbolTable.getConstantValue(as.getIndex()));
-                  final Integer valueAssigned =
-                      (Integer) symbolTable.getConstantValue(as.getValue());
-
-                  assertEquals(
-                      valueAssigned.intValue(),
-                      valueOfArrayIndex + 1,
-                      "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
-                }
-              }
-            }),
-        true,
-        null);
-  }
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testInheritedField() throws IllegalArgumentException, CancelException, IOException {
-    List<EdgeAssertions> edgeAssertionses =
-        Arrays.asList(
-            EdgeAssertions.make(
-                "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
-            EdgeAssertions.make(
-                "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), edgeAssertionses, true, null);
-  }
+            // todo: this fails: assertNotNull("Expected to be enclosed in
+            // 'StaticNesting'.",
+            // ((JavaSourceLoaderImpl.JavaClass)iClass).getEnclosingClass());
+            // todo: is there the concept of CompilationUnit?
 
-  @Test
-  public void testQualifiedStatic() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            /*
+             * {@link JavaCAst2IRTranslator#getEnclosingType} return null for static inner
+             * classes..?
+             */
+          });
 
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[4];
+  static List<? extends IRAssertion> callAssertionForInnerClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("InnerClass");
 
-              assertTrue(
-                  s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
-                  "Did not find a getstatic instruction.");
-              final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
-              assertEquals(
-                  field.getName().toString(), "value", "Expected a getstatic for 'value'.");
-              assertEquals(
-                  field.getDeclaringClass().getName().toString(),
-                  "LFooQ",
-                  "Expected a getstatic for 'value'.");
-            }),
-        true,
-        null);
-  }
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy());
 
-  @Test
-  public void testStaticNesting() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest() + "$WhatsIt";
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              // todo: this fails: assertNotNull("Expected to be enclosed in
-              // 'StaticNesting'.",
-              // ((JavaSourceLoaderImpl.JavaClass)iClass).getEnclosingClass());
-              // todo: is there the concept of CompilationUnit?
-
-              /*
-               * {@link JavaCAst2IRTranslator#getEnclosingType} return null for static inner
-               * classes..?
-               */
-            }),
-        true,
-        null);
-  }
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testCastFromNull() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
-  }
+            assertEquals(
+                ((JavaClass) iClass).getEnclosingClass(),
+                cg.getClassHierarchy()
+                    .lookupClass(
+                        findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy())),
+                "Expected to be enclosed in 'InnerClass'.");
+          });
+
+  static List<? extends IRAssertion> callAssertionForLocalClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("LocalClass");
+            final String localClassStr = "Foo";
+
+            // Observe the descriptor for a class local to a method.
+            final TypeReference mainFooType =
+                findOrCreateTypeReference(
+                    "Source",
+                    typeStr + "/main([Ljava/lang/String;)V/" + localClassStr,
+                    cg.getClassHierarchy());
+
+            // Observe the descriptor for a class local to a method.
+            final IClass mainFooClass = cg.getClassHierarchy().lookupClass(mainFooType);
+            assertNotNull(mainFooClass, "Could not find class " + mainFooType);
+
+            final TypeReference methodFooType =
+                findOrCreateTypeReference(
+                    "Source", typeStr + "/method()V/" + localClassStr, cg.getClassHierarchy());
+
+            final IClass methodFooClass = cg.getClassHierarchy().lookupClass(methodFooType);
+            assertNotNull(methodFooClass, "Could not find class " + methodFooType);
+
+            final IClass localClass =
+                cg.getClassHierarchy()
+                    .lookupClass(
+                        findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy()));
+
+            assertSame(
+                ((JavaClass) methodFooClass).getEnclosingClass(),
+                localClass,
+                "'Foo' is enclosed in 'Local'");
+            // todo: is this failing because 'main' is static?
+            // assertSame("'Foo' is enclosed in 'Local'",
+            // ((JavaSourceLoaderImpl.JavaClass)mainFooClass).getEnclosingClass(),
+            // localClass);
+          });
+  static List<? extends IRAssertion> callAssertionForAnonymousClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("AnonymousClass");
 
-  @Test
-  public void testInnerClass() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest();
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            // todo what to check?? could not find anything in the APIs for
+            // anonymous
+          });
 
-              assertEquals(
-                  ((JavaClass) iClass).getEnclosingClass(),
-                  cg.getClassHierarchy()
-                      .lookupClass(
-                          findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy())),
-                  "Expected to be enclosed in 'InnerClass'.");
-            }),
-        true,
-        null);
-  }
+  private static final List<IRAssertion> MLAssertions =
+      Collections.singletonList(
+          new InstructionOperandAssertion(
+              "Source#MiniaturList#main#([Ljava/lang/String;)V",
+              t -> (t instanceof SSAAbstractInvokeInstruction) && t.toString().contains("cons"),
+              1,
+              new int[] {53, 38, 53, 60}));
 
-  @Test
-  public void testNullArrayInit() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+  static Stream<Arguments> javaIRTestsParameters() {
+    return Stream.of(
+        Arguments.of("AnonymousClass", callAssertionForAnonymousClass, true, null),
+        Arguments.of("Array1", callAssertionForArray1, true, null),
+        Arguments.of("ArrayLiteral1", callAssertionForArrayLiteral1, true, null),
+        Arguments.of("ArrayLiteral2", callAssertionForArrayLiteral2, true, null),
+        Arguments.of("Breaks", emptyList, true, null),
+        Arguments.of("CastFromNull", emptyList, true, null),
+        Arguments.of("Casts", emptyList, true, null),
+        Arguments.of("Exception1", emptyList, true, null),
+        Arguments.of("Exception2", emptyList, true, null),
+        Arguments.of("Finally1", emptyList, true, null),
+        Arguments.of("Inheritance1", callAssertionForInheritance1, true, null),
+        Arguments.of("InheritedField", edgeAssertionses, true, null),
+        Arguments.of("InnerClass", callAssertionForInnerClass, true, null),
+        Arguments.of("InterfaceTest1", callAssertionForInterfaceTest1, true, null),
+        Arguments.of("LexicalAccessOfMethodVariablesFromAnonymousClass", emptyList, true, null),
+        Arguments.of("LocalClass", callAssertionForLocalClass, true, null),
+        Arguments.of("MiniaturList", MLAssertions, true, null),
+        Arguments.of("Monitor", emptyList, true, null),
+        Arguments.of("NullArrayInit", emptyList, true, null),
+        Arguments.of("QualifiedStatic", callAssertionForQualifiedStatic, true, null),
+        Arguments.of("Scoping1", emptyList, true, null),
+        Arguments.of("Scoping2", emptyList, true, null),
+        Arguments.of("Simple1", callAssertionForsimple1, true, null),
+        Arguments.of("StaticInitializers", emptyList, true, null),
+        Arguments.of("StaticNesting", callAssertionForStaticNesting, true, null),
+        Arguments.of("Switch1", emptyList, true, null),
+        Arguments.of("Thread1", emptyList, true, null),
+        Arguments.of("TwoClasses", callAssertionForTwoClasses, true, null),
+        Arguments.of("WhileTest1", emptyList, true, null));
+  }
+
+  static Stream<Arguments> javaIRTestsParametersWithPackageName() {
+    return Stream.of(
+        Arguments.of("bugfixes", "DoWhileInCase", emptyList, true, null),
+        Arguments.of("bugfixes", "VarDeclInSwitch", emptyList, true, null),
+        Arguments.of("p", "NonPrimaryTopLevel", emptyList, true, null));
+  }
+
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParameters")
+  public void runJavaIRTests(
+      String java17IRTestName, List<IRAssertion> ca, boolean assertReachable, String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
+    runTest(
+        singleTestSrc(java17IRTestName),
+        rtJar,
+        simpleTestEntryPoint(java17IRTestName),
+        ca,
+        assertReachable,
+        exclusionsFile);
+  }
+
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParametersWithPackageName")
+  public void runJavaIRTestsWithPackageName(
+      String packageName,
+      String testName,
+      List<IRAssertion> callAssertion,
+      boolean assertReachable,
+      String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
+    runTest(
+        singlePkgTestSrc(packageName, testName),
+        rtJar,
+        simplePkgTestEntryPoint(packageName, testName),
+        callAssertion,
+        assertReachable,
+        exclusionsFile);
   }
 
   @Test
   public void testInnerClassA() throws IllegalArgumentException, CancelException, IOException {
-    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x = runTest("InnerClassA");
 
     // can't do an IRAssertion() -- we need the pointer analysis
 
@@ -511,8 +547,7 @@ public void testInnerClassA() throws IllegalArgumentException, CancelException,
 
   @Test
   public void testInnerClassSuper() throws IllegalArgumentException, CancelException, IOException {
-    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x = runTest("InnerClassSuper");
 
     // can't do an IRAssertion() -- we need the pointer analysis
 
@@ -542,161 +577,6 @@ public void testInnerClassSuper() throws IllegalArgumentException, CancelExcepti
     }
   }
 
-  @Test
-  public void testLocalClass() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest();
-              final String localClassStr = "Foo";
-
-              // Observe the descriptor for a class local to a method.
-              final TypeReference mainFooType =
-                  findOrCreateTypeReference(
-                      "Source",
-                      typeStr + "/main([Ljava/lang/String;)V/" + localClassStr,
-                      cg.getClassHierarchy());
-
-              // Observe the descriptor for a class local to a method.
-              final IClass mainFooClass = cg.getClassHierarchy().lookupClass(mainFooType);
-              assertNotNull(mainFooClass, "Could not find class " + mainFooType);
-
-              final TypeReference methodFooType =
-                  findOrCreateTypeReference(
-                      "Source", typeStr + "/method()V/" + localClassStr, cg.getClassHierarchy());
-
-              final IClass methodFooClass = cg.getClassHierarchy().lookupClass(methodFooType);
-              assertNotNull(methodFooClass, "Could not find class " + methodFooType);
-
-              final IClass localClass =
-                  cg.getClassHierarchy()
-                      .lookupClass(
-                          findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy()));
-
-              assertSame(
-                  ((JavaClass) methodFooClass).getEnclosingClass(),
-                  localClass,
-                  "'Foo' is enclosed in 'Local'");
-              // todo: is this failing because 'main' is static?
-              // assertSame("'Foo' is enclosed in 'Local'",
-              // ((JavaSourceLoaderImpl.JavaClass)mainFooClass).getEnclosingClass(),
-              // localClass);
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testAnonymousClass() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest();
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              // todo what to check?? could not find anything in the APIs for
-              // anonymous
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testWhileTest1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testSwitch1() {
-    try {
-      runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-    } catch (IllegalArgumentException | IOException | CancelException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
-    }
-  }
-
-  @Test
-  public void testException1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testException2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testFinally1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testScoping1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testScoping2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testNonPrimaryTopLevel()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(singlePkgTestSrc("p"), rtJar, simplePkgTestEntryPoint("p"), emptyList, true, null);
-  }
-
-  private static final List<IRAssertion> MLAssertions =
-      Collections.singletonList(
-          new InstructionOperandAssertion(
-              "Source#MiniaturList#main#([Ljava/lang/String;)V",
-              t -> (t instanceof SSAAbstractInvokeInstruction) && t.toString().contains("cons"),
-              1,
-              new int[] {53, 38, 53, 60}));
-
-  @Test
-  public void testMiniaturList() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), MLAssertions, true, null);
-  }
-
-  @Test
-  public void testMonitor() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testStaticInitializers()
-      throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testThread1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testCasts() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
-  @Test
-  public void testBreaks() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
-
   private static MethodReference getSliceRootReference(
       String className, String methodName, String methodDescriptor) {
     TypeName clsName = TypeName.string2TypeName('L' + className.replace('.', '/'));
@@ -710,8 +590,7 @@ private static MethodReference getSliceRootReference(
 
   @Test
   public void testMiniaturSliceBug() throws IllegalArgumentException, CancelException, IOException {
-    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
+    Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x = runTest("MiniaturSliceBug");
 
     PointerAnalysis<? extends InstanceKey> pa =
         ((PropagationCallGraphBuilder) x.snd).getPointerAnalysis();
@@ -770,28 +649,6 @@ public void testThinSlice() throws CancelException, IOException {
     dumpSlice(slice);
   }
 
-  @Test
-  public void testDoWhileInCase() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc("bugfixes"),
-        rtJar,
-        simplePkgTestEntryPoint("bugfixes"),
-        emptyList,
-        true,
-        null);
-  }
-
-  @Test
-  public void testVarDeclInSwitch() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc("bugfixes"),
-        rtJar,
-        simplePkgTestEntryPoint("bugfixes"),
-        emptyList,
-        true,
-        null);
-  }
-
   @Test
   public void testExclusions(@TempDir final File tmpDir)
       throws IllegalArgumentException, CancelException, IOException {
@@ -800,9 +657,9 @@ public void testExclusions(@TempDir final File tmpDir)
             File.createTempFile("exl", "txt", tmpDir), "Exclusions.Excluded\n");
     Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x =
         runTest(
-            singleTestSrc(),
+            singleTestSrc("Exclusions"),
             rtJar,
-            simpleTestEntryPoint(),
+            simpleTestEntryPoint("Exclusions"),
             emptyList,
             true,
             exclusions.getAbsolutePath());
@@ -823,10 +680,4 @@ public void testExclusions(@TempDir final File tmpDir)
             JavaSourceAnalysisScope.SOURCE, TypeName.findOrCreate("LExclusions$Excluded"));
     assert cha.lookupClass(exclType) == null;
   }
-
-  @Test
-  public void testLexicalAccessOfMethodVariablesFromAnonymousClass()
-      throws CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
-  }
 }
diff --git a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/SyncDuplicatorTests.java b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/SyncDuplicatorTests.java
index d0493a8d65..bf3bb3ed85 100644
--- a/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/SyncDuplicatorTests.java
+++ b/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/SyncDuplicatorTests.java
@@ -41,6 +41,7 @@ public SyncDuplicatorTests() {
 
   @Test
   public void testMonitor2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true, null);
+    runTest(
+        singleTestSrc("Monitor2"), rtJar, simpleTestEntryPoint("Monitor2"), emptyList, true, null);
   }
 }


Reviews:
user: login: liblit
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T22:19:56Z
user: login: msridhar
body: Looking great!  A couple of comments particularly on `JavaIRTests`
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-08T21:03:12Z
user: login: jkhaliqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T17:53:04Z
user: login: jkhaliqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T17:53:42Z
user: login: msridhar
body: Thanks again so much for this cleanup!  One more comment / question
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-12T15:07:38Z
user: login: jkhaliqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T23:08:06Z
user: login: msridhar
state: DISMISSED
author_association: MEMBER
submitted_at: 2025-03-13T01:35:16Z
user: login: liblit
body: According to [this bot comment](https://github.com/wala/WALA/pull/1485#issuecomment-2704954733), this change results in a net increase of 101 tests. Is that expected?
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-13T01:44:00Z
user: login: liblit
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-22T00:07:01Z

Review comments:
diff_hunk: @@ -39,241 +41,39 @@ protected Iterable<Entrypoint> makeDefaultEntrypoints(IClassHierarchy cha) {
     return engine;
   }
 
-  @Test
-  public void testVarargsOverriding()
+  static Stream<String> java15IRTestNames() {
+    return Stream.of(
+        "VarargsOverriding",
+        "EnumSwitch",
+        "OverridesOnePointFour",
+        "VarargsCovariant",
+        "SimpleEnums",
+        "GenericSuperSink",
+        "AnonGeneNullarySimple",
+        "AnonymousGenerics",
+        "NotSoSimpleEnums",
+        "Varargs",
+        "GenericArrays",
+        "Annotations",
+        "Cocovariant",
+        "ExplicitBoxingTest",
+        "Wildcards",
+        "BasicsGenerics",
+        "CustomGenericsAndFields",
+        "TypeInferencePrimAndStringOp",
+        "SimpleEnums2",
+        "GenericMemberClasses",
+        "MoreOverriddenGenerics");
path: cast/java/ecj/src/test/java/com/ibm/wala/cast/java/test/ECJJava15IRTest.java
user: login: liblit
body: If the order of these items does not matter, then please sort them alphabetically. That will make this list easier to scan when adding new items, easier to avoid adding duplicates, etc..
created_at: 2025-03-06T22:19:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -80,295 +84,271 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> caForInterfaceTest1 =
path: cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
user: login: msridhar
body: This naming scheme `caForXXX` is confusing.  What does `ca` mean?  Can we use something more descriptive?
created_at: 2025-03-08T20:57:30Z
author_association: MEMBER
diff_hunk: @@ -80,295 +84,271 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> caForInterfaceTest1 =
+      Arrays.asList(
+          cg -> {
+            final String typeStr = "IFoo";
 
-  @Test
-  public void testInterfaceTest1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Arrays.asList(
-            cg -> {
-              final String typeStr = "IFoo";
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
+          },
+          cg -> {
+            final String typeStr = "FooIT1";
 
-              assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
-            },
-            cg -> {
-              final String typeStr = "FooIT1";
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
 
-              final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
+            assertEquals(interfaces.size(), 1, "Expected one single interface.");
 
-              assertEquals(interfaces.size(), 1, "Expected one single interface.");
+            assertTrue(
+                interfaces.contains(
+                    cg.getClassHierarchy()
+                        .lookupClass(
+                            findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
+                "Expected Foo to implement IFoo");
+          });
 
-              assertTrue(
-                  interfaces.contains(
-                      cg.getClassHierarchy()
-                          .lookupClass(
-                              findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
-                  "Expected Foo to implement IFoo");
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> caForInheritance1 =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = "Derived";
 
-  @Test
-  public void testInheritance1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = "Derived";
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(derivedClass, "Could not find class " + typeStr);
 
-              final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(derivedClass, "Could not find class " + typeStr);
+            final TypeReference baseType =
+                findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
+            final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
 
-              final TypeReference baseType =
-                  findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
-              final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
+            assertEquals(
+                derivedClass.getSuperclass(),
+                baseClass,
+                "Expected 'Base' to be the superclass of 'Derived'");
 
-              assertEquals(
-                  derivedClass.getSuperclass(),
-                  baseClass,
-                  "Expected 'Base' to be the superclass of 'Derived'");
+            Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
 
-              Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
+            assertTrue(
+                subclasses.contains(derivedClass) && subclasses.contains(baseClass),
+                "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
+          });
 
-              assertTrue(
-                  subclasses.contains(derivedClass) && subclasses.contains(baseClass),
-                  "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testArray1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            /*
-             * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
-             * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
-             */
-            new IRAssertion() {
-
-              @Override
-              public void check(CallGraph cg) {
-
-                MethodReference mref =
-                    descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
-
-                int count = 0;
-                CGNode node = cg.getNodes(mref).iterator().next();
-                for (SSAInstruction s : node.getIR().getInstructions()) {
-                  if (isArrayInstruction(s)) {
-                    count++;
-                  }
-                }
+  static List<? extends IRAssertion> caForArrayLiteral1 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[2];
+            assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
+            assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
+          });
+
+  static List<? extends IRAssertion> caForQualifiedStatic =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[4];
+
+            assertTrue(
+                s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
+                "Did not find a getstatic instruction.");
+            final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
+            assertEquals(field.getName().toString(), "value", "Expected a getstatic for 'value'.");
+            assertEquals(
+                field.getDeclaringClass().getName().toString(),
+                "LFooQ",
+                "Expected a getstatic for 'value'.");
+          });
 
-                assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+  static List<? extends IRAssertion> caForArrayLiteral2 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+
+            final SSAInstruction[] instructions = node.getIR().getInstructions();
+            // test 1
+            {
+              SSAInstruction s1 = instructions[2];
+              if (s1 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 3rd to be a new array instruction.");
               }
-
-              private boolean isArrayInstruction(SSAInstruction s) {
-                return s instanceof SSAArrayReferenceInstruction
-                    || s instanceof SSAArrayLengthInstruction;
+            }
+            // test 2
+            {
+              SSAInstruction s2 = instructions[3];
+              if (s2 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 4th to be a new array instruction.");
               }
-            }),
-        true,
-        null);
+            }
+            // test 3: the last 4 instructions are of the form y[i] = i+1;
+            {
+              final SymbolTable symbolTable = node.getIR().getSymbolTable();
+              for (int i = 4; i <= 7; i++) {
+                assertInstanceOf(
+                    SSAArrayStoreInstruction.class, instructions[i], "Expected only array stores.");
+
+                SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
+
+                assertEquals(
+                    node.getIR().getLocalNames(i, as.getArrayRef())[0],
+                    "y",
+                    "Expected an array store to 'y'.");
+
+                final Integer valueOfArrayIndex =
+                    ((Integer) symbolTable.getConstantValue(as.getIndex()));
+                final Integer valueAssigned = (Integer) symbolTable.getConstantValue(as.getValue());
+
+                assertEquals(
+                    valueAssigned.intValue(),
+                    valueOfArrayIndex + 1,
+                    "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
+              }
+            }
+          });
+
+  static List<EdgeAssertions> edgeAssertionses =
+      Arrays.asList(
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
+
+  static Stream<Arguments> javaIRTestsParameters() {
+    return Stream.of(
+        Arguments.of(
+            "Array1",
+            Collections.singletonList(
+                /*
+                 * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
+                 * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
+                 */
+                new IRAssertion() {
+
+                  @Override
+                  public void check(CallGraph cg) {
+
+                    MethodReference mref =
+                        descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
+
+                    int count = 0;
+                    CGNode node = cg.getNodes(mref).iterator().next();
+                    for (SSAInstruction s : node.getIR().getInstructions()) {
+                      if (isArrayInstruction(s)) {
+                        count++;
+                      }
+                    }
+
+                    assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+                  }
+
+                  private boolean isArrayInstruction(SSAInstruction s) {
+                    return s instanceof SSAArrayReferenceInstruction
+                        || s instanceof SSAArrayLengthInstruction;
+                  }
+                }),
+            true,
+            null),
+        Arguments.of("ArrayLiteral1", caForArrayLiteral1, true, null),
+        Arguments.of("ArrayLiteral2", caForArrayLiteral2, true, null),
+        Arguments.of("Breaks", emptyList, true, null),
+        Arguments.of("CastFromNull", emptyList, true, null),
+        Arguments.of("Casts", emptyList, true, null),
+        Arguments.of("Exception1", emptyList, true, null),
+        Arguments.of("Exception2", emptyList, true, null),
+        Arguments.of("Finally1", emptyList, true, null),
+        Arguments.of("Inheritance1", caForInheritance1, true, null),
+        Arguments.of("InheritedField", edgeAssertionses, true, null),
+        Arguments.of("InterfaceTest1", caForInterfaceTest1, true, null),
+        Arguments.of("MiniaturList", MLAssertions, true, null),
+        Arguments.of("Monitor", emptyList, true, null),
+        Arguments.of("NullArrayInit", emptyList, true, null),
+        Arguments.of("QualifiedStatic", caForQualifiedStatic, true, null),
+        Arguments.of(
+            "Simple1",
+            Arrays.asList(
+                new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
+                new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
+                new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
+                new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
+                new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
+                EdgeAssertions.make(
+                    "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
+                EdgeAssertions.make(
+                    "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V")),
+            true,
+            null),
+        Arguments.of("Thread1", emptyList, true, null),
+        Arguments.of("WhileTest1", emptyList, true, null));
   }
 
-  @Test
-  public void testArrayLiteral1() throws IllegalArgumentException, CancelException, IOException {
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParameters")
+  public void runJavaIRTests(
+      String java17IRTestName, List<IRAssertion> ca, boolean assertReachable, String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
     runTest(
-        singleTestSrc(),
+        singleTestSrc(java17IRTestName),
         rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
-
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[2];
-              assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
-              assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
-            }),
-        true,
-        null);
+        simpleTestEntryPoint(java17IRTestName),
+        ca,
+        assertReachable,
+        exclusionsFile);
   }
 
   @Test
-  public void testArrayLiteral2() throws IllegalArgumentException, CancelException, IOException {
+  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
path: cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
user: login: msridhar
body: Why are the remaining tests still here and not just run via the parameterized tests?
created_at: 2025-03-08T20:59:18Z
author_association: MEMBER
diff_hunk: @@ -80,295 +84,271 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> caForInterfaceTest1 =
path: cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
user: login: jkhaliqi
body: I wasn't exactly sure what `ca` also meant I got this variable name from the fourth parameter inside of `runTests`. But i'm assuming it has something to do with the `callGraph` and just changed it to be `callAssertionsForXXX`. Let me know if theres a better name.
created_at: 2025-03-10T17:53:04Z
author_association: CONTRIBUTOR
diff_hunk: @@ -80,295 +84,271 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> caForInterfaceTest1 =
+      Arrays.asList(
+          cg -> {
+            final String typeStr = "IFoo";
 
-  @Test
-  public void testInterfaceTest1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Arrays.asList(
-            cg -> {
-              final String typeStr = "IFoo";
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
+          },
+          cg -> {
+            final String typeStr = "FooIT1";
 
-              assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
-            },
-            cg -> {
-              final String typeStr = "FooIT1";
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
 
-              final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
+            assertEquals(interfaces.size(), 1, "Expected one single interface.");
 
-              assertEquals(interfaces.size(), 1, "Expected one single interface.");
+            assertTrue(
+                interfaces.contains(
+                    cg.getClassHierarchy()
+                        .lookupClass(
+                            findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
+                "Expected Foo to implement IFoo");
+          });
 
-              assertTrue(
-                  interfaces.contains(
-                      cg.getClassHierarchy()
-                          .lookupClass(
-                              findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
-                  "Expected Foo to implement IFoo");
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> caForInheritance1 =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = "Derived";
 
-  @Test
-  public void testInheritance1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = "Derived";
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(derivedClass, "Could not find class " + typeStr);
 
-              final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(derivedClass, "Could not find class " + typeStr);
+            final TypeReference baseType =
+                findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
+            final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
 
-              final TypeReference baseType =
-                  findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
-              final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
+            assertEquals(
+                derivedClass.getSuperclass(),
+                baseClass,
+                "Expected 'Base' to be the superclass of 'Derived'");
 
-              assertEquals(
-                  derivedClass.getSuperclass(),
-                  baseClass,
-                  "Expected 'Base' to be the superclass of 'Derived'");
+            Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
 
-              Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
+            assertTrue(
+                subclasses.contains(derivedClass) && subclasses.contains(baseClass),
+                "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
+          });
 
-              assertTrue(
-                  subclasses.contains(derivedClass) && subclasses.contains(baseClass),
-                  "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testArray1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            /*
-             * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
-             * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
-             */
-            new IRAssertion() {
-
-              @Override
-              public void check(CallGraph cg) {
-
-                MethodReference mref =
-                    descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
-
-                int count = 0;
-                CGNode node = cg.getNodes(mref).iterator().next();
-                for (SSAInstruction s : node.getIR().getInstructions()) {
-                  if (isArrayInstruction(s)) {
-                    count++;
-                  }
-                }
+  static List<? extends IRAssertion> caForArrayLiteral1 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[2];
+            assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
+            assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
+          });
+
+  static List<? extends IRAssertion> caForQualifiedStatic =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[4];
+
+            assertTrue(
+                s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
+                "Did not find a getstatic instruction.");
+            final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
+            assertEquals(field.getName().toString(), "value", "Expected a getstatic for 'value'.");
+            assertEquals(
+                field.getDeclaringClass().getName().toString(),
+                "LFooQ",
+                "Expected a getstatic for 'value'.");
+          });
 
-                assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+  static List<? extends IRAssertion> caForArrayLiteral2 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+
+            final SSAInstruction[] instructions = node.getIR().getInstructions();
+            // test 1
+            {
+              SSAInstruction s1 = instructions[2];
+              if (s1 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 3rd to be a new array instruction.");
               }
-
-              private boolean isArrayInstruction(SSAInstruction s) {
-                return s instanceof SSAArrayReferenceInstruction
-                    || s instanceof SSAArrayLengthInstruction;
+            }
+            // test 2
+            {
+              SSAInstruction s2 = instructions[3];
+              if (s2 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 4th to be a new array instruction.");
               }
-            }),
-        true,
-        null);
+            }
+            // test 3: the last 4 instructions are of the form y[i] = i+1;
+            {
+              final SymbolTable symbolTable = node.getIR().getSymbolTable();
+              for (int i = 4; i <= 7; i++) {
+                assertInstanceOf(
+                    SSAArrayStoreInstruction.class, instructions[i], "Expected only array stores.");
+
+                SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
+
+                assertEquals(
+                    node.getIR().getLocalNames(i, as.getArrayRef())[0],
+                    "y",
+                    "Expected an array store to 'y'.");
+
+                final Integer valueOfArrayIndex =
+                    ((Integer) symbolTable.getConstantValue(as.getIndex()));
+                final Integer valueAssigned = (Integer) symbolTable.getConstantValue(as.getValue());
+
+                assertEquals(
+                    valueAssigned.intValue(),
+                    valueOfArrayIndex + 1,
+                    "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
+              }
+            }
+          });
+
+  static List<EdgeAssertions> edgeAssertionses =
+      Arrays.asList(
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
+
+  static Stream<Arguments> javaIRTestsParameters() {
+    return Stream.of(
+        Arguments.of(
+            "Array1",
+            Collections.singletonList(
+                /*
+                 * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
+                 * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
+                 */
+                new IRAssertion() {
+
+                  @Override
+                  public void check(CallGraph cg) {
+
+                    MethodReference mref =
+                        descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
+
+                    int count = 0;
+                    CGNode node = cg.getNodes(mref).iterator().next();
+                    for (SSAInstruction s : node.getIR().getInstructions()) {
+                      if (isArrayInstruction(s)) {
+                        count++;
+                      }
+                    }
+
+                    assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+                  }
+
+                  private boolean isArrayInstruction(SSAInstruction s) {
+                    return s instanceof SSAArrayReferenceInstruction
+                        || s instanceof SSAArrayLengthInstruction;
+                  }
+                }),
+            true,
+            null),
+        Arguments.of("ArrayLiteral1", caForArrayLiteral1, true, null),
+        Arguments.of("ArrayLiteral2", caForArrayLiteral2, true, null),
+        Arguments.of("Breaks", emptyList, true, null),
+        Arguments.of("CastFromNull", emptyList, true, null),
+        Arguments.of("Casts", emptyList, true, null),
+        Arguments.of("Exception1", emptyList, true, null),
+        Arguments.of("Exception2", emptyList, true, null),
+        Arguments.of("Finally1", emptyList, true, null),
+        Arguments.of("Inheritance1", caForInheritance1, true, null),
+        Arguments.of("InheritedField", edgeAssertionses, true, null),
+        Arguments.of("InterfaceTest1", caForInterfaceTest1, true, null),
+        Arguments.of("MiniaturList", MLAssertions, true, null),
+        Arguments.of("Monitor", emptyList, true, null),
+        Arguments.of("NullArrayInit", emptyList, true, null),
+        Arguments.of("QualifiedStatic", caForQualifiedStatic, true, null),
+        Arguments.of(
+            "Simple1",
+            Arrays.asList(
+                new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
+                new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
+                new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
+                new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
+                new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
+                EdgeAssertions.make(
+                    "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
+                EdgeAssertions.make(
+                    "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V")),
+            true,
+            null),
+        Arguments.of("Thread1", emptyList, true, null),
+        Arguments.of("WhileTest1", emptyList, true, null));
   }
 
-  @Test
-  public void testArrayLiteral1() throws IllegalArgumentException, CancelException, IOException {
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParameters")
+  public void runJavaIRTests(
+      String java17IRTestName, List<IRAssertion> ca, boolean assertReachable, String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
     runTest(
-        singleTestSrc(),
+        singleTestSrc(java17IRTestName),
         rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
-
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[2];
-              assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
-              assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
-            }),
-        true,
-        null);
+        simpleTestEntryPoint(java17IRTestName),
+        ca,
+        assertReachable,
+        exclusionsFile);
   }
 
   @Test
-  public void testArrayLiteral2() throws IllegalArgumentException, CancelException, IOException {
+  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
path: cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
user: login: jkhaliqi
body: Some of the remaining tests call runTests and store its output in a variable and then do other stuff with it so I just left those alone.
created_at: 2025-03-10T17:53:42Z
author_association: CONTRIBUTOR
diff_hunk: @@ -80,371 +84,411 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
+  static List<? extends IRAssertion> callAssertionForInterfaceTest1 =
+      Arrays.asList(
+          cg -> {
+            final String typeStr = "IFoo";
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testInterfaceTest1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Arrays.asList(
-            cg -> {
-              final String typeStr = "IFoo";
+            assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
+          },
+          cg -> {
+            final String typeStr = "FooIT1";
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
-            },
-            cg -> {
-              final String typeStr = "FooIT1";
+            final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            assertEquals(interfaces.size(), 1, "Expected one single interface.");
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            assertTrue(
+                interfaces.contains(
+                    cg.getClassHierarchy()
+                        .lookupClass(
+                            findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
+                "Expected Foo to implement IFoo");
+          });
 
-              final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
+  static List<? extends IRAssertion> callAssertionForInheritance1 =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = "Derived";
 
-              assertEquals(interfaces.size(), 1, "Expected one single interface.");
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              assertTrue(
-                  interfaces.contains(
-                      cg.getClassHierarchy()
-                          .lookupClass(
-                              findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
-                  "Expected Foo to implement IFoo");
-            }),
-        true,
-        null);
-  }
+            final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(derivedClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testInheritance1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = "Derived";
+            final TypeReference baseType =
+                findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
+            final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            assertEquals(
+                derivedClass.getSuperclass(),
+                baseClass,
+                "Expected 'Base' to be the superclass of 'Derived'");
 
-              final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(derivedClass, "Could not find class " + typeStr);
+            Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
 
-              final TypeReference baseType =
-                  findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
-              final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
+            assertTrue(
+                subclasses.contains(derivedClass) && subclasses.contains(baseClass),
+                "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
+          });
 
-              assertEquals(
-                  derivedClass.getSuperclass(),
-                  baseClass,
-                  "Expected 'Base' to be the superclass of 'Derived'");
-
-              Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
-
-              assertTrue(
-                  subclasses.contains(derivedClass) && subclasses.contains(baseClass),
-                  "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> callAssertionForArrayLiteral1 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[2];
+            assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
+            assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
+          });
+
+  static List<? extends IRAssertion> callAssertionForQualifiedStatic =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[4];
+
+            assertTrue(
+                s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
+                "Did not find a getstatic instruction.");
+            final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
+            assertEquals(field.getName().toString(), "value", "Expected a getstatic for 'value'.");
+            assertEquals(
+                field.getDeclaringClass().getName().toString(),
+                "LFooQ",
+                "Expected a getstatic for 'value'.");
+          });
 
-  @Test
-  public void testArray1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            /*
-             * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
-             * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
-             */
-            new IRAssertion() {
+  static List<? extends IRAssertion> callAssertionForArrayLiteral2 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+
+            final SSAInstruction[] instructions = node.getIR().getInstructions();
+            // test 1
+            {
+              SSAInstruction s1 = instructions[2];
+              if (s1 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 3rd to be a new array instruction.");
+              }
+            }
+            // test 2
+            {
+              SSAInstruction s2 = instructions[3];
+              if (s2 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 4th to be a new array instruction.");
+              }
+            }
+            // test 3: the last 4 instructions are of the form y[i] = i+1;
+            {
+              final SymbolTable symbolTable = node.getIR().getSymbolTable();
+              for (int i = 4; i <= 7; i++) {
+                assertInstanceOf(
+                    SSAArrayStoreInstruction.class, instructions[i], "Expected only array stores.");
+
+                SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
+
+                assertEquals(
+                    node.getIR().getLocalNames(i, as.getArrayRef())[0],
+                    "y",
+                    "Expected an array store to 'y'.");
+
+                final Integer valueOfArrayIndex =
+                    ((Integer) symbolTable.getConstantValue(as.getIndex()));
+                final Integer valueAssigned = (Integer) symbolTable.getConstantValue(as.getValue());
+
+                assertEquals(
+                    valueAssigned.intValue(),
+                    valueOfArrayIndex + 1,
+                    "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
+              }
+            }
+          });
+
+  static List<EdgeAssertions> edgeAssertionses =
+      Arrays.asList(
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
+  static List<? extends IRAssertion> callAssertionForArray1 =
+      Collections.singletonList(
+          /*
+           * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
+           * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
+           */
+          new IRAssertion() {
 
-              @Override
-              public void check(CallGraph cg) {
+            @Override
+            public void check(CallGraph cg) {
 
-                MethodReference mref =
-                    descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
+              MethodReference mref =
+                  descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
 
-                int count = 0;
-                CGNode node = cg.getNodes(mref).iterator().next();
-                for (SSAInstruction s : node.getIR().getInstructions()) {
-                  if (isArrayInstruction(s)) {
-                    count++;
-                  }
+              int count = 0;
+              CGNode node = cg.getNodes(mref).iterator().next();
+              for (SSAInstruction s : node.getIR().getInstructions()) {
+                if (isArrayInstruction(s)) {
+                  count++;
                 }
-
-                assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
               }
 
-              private boolean isArrayInstruction(SSAInstruction s) {
-                return s instanceof SSAArrayReferenceInstruction
-                    || s instanceof SSAArrayLengthInstruction;
-              }
-            }),
-        true,
-        null);
-  }
+              assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+            }
 
-  @Test
-  public void testArrayLiteral1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            private boolean isArrayInstruction(SSAInstruction s) {
+              return s instanceof SSAArrayReferenceInstruction
+                  || s instanceof SSAArrayLengthInstruction;
+            }
+          });
+
+  static List<? extends IRAssertion> callAssertionForsimple1 =
+      Arrays.asList(
+          new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
+          new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
+          EdgeAssertions.make(
+              "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
+          EdgeAssertions.make(
+              "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
+
+  static List<? extends IRAssertion> callAssertionForTwoClasses =
+      List.of(
+          cg -> {
+            final String typeStr = singleInputForTest("TwoClasses");
+
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[2];
-              assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
-              assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
-            }),
-        true,
-        null);
-  }
+            /*
+            assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
 
-  @Test
-  public void testArrayLiteral2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
+              assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
+                  .equals(typeStr)
+                  || cls.getName().getClassName().toString().equals("Bar"));
+            }
+            */
+          });
+  static List<? extends IRAssertion> callAssertionForStaticNesting =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("StaticNesting") + "$WhatsIt";
 
-              CGNode node = cg.getNodes(mref).iterator().next();
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final SSAInstruction[] instructions = node.getIR().getInstructions();
-              // test 1
-              {
-                SSAInstruction s1 = instructions[2];
-                if (s1 instanceof SSANewInstruction) {
-                  assertTrue(
-                      ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
-                } else {
-                  fail("Expected 3rd to be a new array instruction.");
-                }
-              }
-              // test 2
-              {
-                SSAInstruction s2 = instructions[3];
-                if (s2 instanceof SSANewInstruction) {
-                  assertTrue(
-                      ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
-                } else {
-                  fail("Expected 4th to be a new array instruction.");
-                }
-              }
-              // test 3: the last 4 instructions are of the form y[i] = i+1;
-              {
-                final SymbolTable symbolTable = node.getIR().getSymbolTable();
-                for (int i = 4; i <= 7; i++) {
-                  assertInstanceOf(
-                      SSAArrayStoreInstruction.class,
-                      instructions[i],
-                      "Expected only array stores.");
-
-                  SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
-
-                  assertEquals(
-                      node.getIR().getLocalNames(i, as.getArrayRef())[0],
-                      "y",
-                      "Expected an array store to 'y'.");
-
-                  final Integer valueOfArrayIndex =
-                      ((Integer) symbolTable.getConstantValue(as.getIndex()));
-                  final Integer valueAssigned =
-                      (Integer) symbolTable.getConstantValue(as.getValue());
-
-                  assertEquals(
-                      valueAssigned.intValue(),
-                      valueOfArrayIndex + 1,
-                      "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
-                }
-              }
-            }),
-        true,
-        null);
-  }
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testInheritedField() throws IllegalArgumentException, CancelException, IOException {
-    List<EdgeAssertions> edgeAssertionses =
-        Arrays.asList(
-            EdgeAssertions.make(
-                "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
-            EdgeAssertions.make(
-                "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), edgeAssertionses, true, null);
-  }
+            // todo: this fails: assertNotNull("Expected to be enclosed in
+            // 'StaticNesting'.",
+            // ((JavaSourceLoaderImpl.JavaClass)iClass).getEnclosingClass());
+            // todo: is there the concept of CompilationUnit?
 
-  @Test
-  public void testQualifiedStatic() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            /*
+             * {@link JavaCAst2IRTranslator#getEnclosingType} return null for static inner
+             * classes..?
+             */
+          });
 
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[4];
+  static List<? extends IRAssertion> callAssertionForInnerClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("InnerClass");
 
-              assertTrue(
-                  s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
-                  "Did not find a getstatic instruction.");
-              final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
-              assertEquals(
-                  field.getName().toString(), "value", "Expected a getstatic for 'value'.");
-              assertEquals(
-                  field.getDeclaringClass().getName().toString(),
-                  "LFooQ",
-                  "Expected a getstatic for 'value'.");
-            }),
-        true,
-        null);
-  }
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy());
 
-  @Test
-  public void testStaticNesting() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest() + "$WhatsIt";
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              // todo: this fails: assertNotNull("Expected to be enclosed in
-              // 'StaticNesting'.",
-              // ((JavaSourceLoaderImpl.JavaClass)iClass).getEnclosingClass());
-              // todo: is there the concept of CompilationUnit?
-
-              /*
-               * {@link JavaCAst2IRTranslator#getEnclosingType} return null for static inner
-               * classes..?
-               */
-            }),
-        true,
-        null);
-  }
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testCastFromNull() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
-  }
+            assertEquals(
+                ((JavaClass) iClass).getEnclosingClass(),
+                cg.getClassHierarchy()
+                    .lookupClass(
+                        findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy())),
+                "Expected to be enclosed in 'InnerClass'.");
+          });
+
+  static List<? extends IRAssertion> callAssertionForLocalClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("LocalClass");
+            final String localClassStr = "Foo";
+
+            // Observe the descriptor for a class local to a method.
+            final TypeReference mainFooType =
+                findOrCreateTypeReference(
+                    "Source",
+                    typeStr + "/main([Ljava/lang/String;)V/" + localClassStr,
+                    cg.getClassHierarchy());
+
+            // Observe the descriptor for a class local to a method.
+            final IClass mainFooClass = cg.getClassHierarchy().lookupClass(mainFooType);
+            assertNotNull(mainFooClass, "Could not find class " + mainFooType);
+
+            final TypeReference methodFooType =
+                findOrCreateTypeReference(
+                    "Source", typeStr + "/method()V/" + localClassStr, cg.getClassHierarchy());
+
+            final IClass methodFooClass = cg.getClassHierarchy().lookupClass(methodFooType);
+            assertNotNull(methodFooClass, "Could not find class " + methodFooType);
+
+            final IClass localClass =
+                cg.getClassHierarchy()
+                    .lookupClass(
+                        findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy()));
+
+            assertSame(
+                ((JavaClass) methodFooClass).getEnclosingClass(),
+                localClass,
+                "'Foo' is enclosed in 'Local'");
+            // todo: is this failing because 'main' is static?
+            // assertSame("'Foo' is enclosed in 'Local'",
+            // ((JavaSourceLoaderImpl.JavaClass)mainFooClass).getEnclosingClass(),
+            // localClass);
+          });
+  static List<? extends IRAssertion> callAssertionForAnonymousClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("AnonymousClass");
 
-  @Test
-  public void testInnerClass() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest();
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            // todo what to check?? could not find anything in the APIs for
+            // anonymous
+          });
 
-              assertEquals(
-                  ((JavaClass) iClass).getEnclosingClass(),
-                  cg.getClassHierarchy()
-                      .lookupClass(
-                          findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy())),
-                  "Expected to be enclosed in 'InnerClass'.");
-            }),
-        true,
-        null);
-  }
+  private static final List<IRAssertion> MLAssertions =
+      Collections.singletonList(
+          new InstructionOperandAssertion(
+              "Source#MiniaturList#main#([Ljava/lang/String;)V",
+              t -> (t instanceof SSAAbstractInvokeInstruction) && t.toString().contains("cons"),
+              1,
+              new int[] {53, 38, 53, 60}));
 
-  @Test
-  public void testNullArrayInit() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+  static Stream<Arguments> javaIRTestsParameters() {
+    return Stream.of(
+        Arguments.of("AnonymousClass", callAssertionForAnonymousClass, true, null),
+        Arguments.of("Array1", callAssertionForArray1, true, null),
+        Arguments.of("ArrayLiteral1", callAssertionForArrayLiteral1, true, null),
+        Arguments.of("ArrayLiteral2", callAssertionForArrayLiteral2, true, null),
+        Arguments.of("Breaks", emptyList, true, null),
+        Arguments.of("CastFromNull", emptyList, true, null),
+        Arguments.of("Casts", emptyList, true, null),
+        Arguments.of("Exception1", emptyList, true, null),
+        Arguments.of("Exception2", emptyList, true, null),
+        Arguments.of("Finally1", emptyList, true, null),
+        Arguments.of("Inheritance1", callAssertionForInheritance1, true, null),
+        Arguments.of("InheritedField", edgeAssertionses, true, null),
+        Arguments.of("InnerClass", callAssertionForInnerClass, true, null),
+        Arguments.of("InterfaceTest1", callAssertionForInterfaceTest1, true, null),
+        Arguments.of("LexicalAccessOfMethodVariablesFromAnonymousClass", emptyList, true, null),
+        Arguments.of("LocalClass", callAssertionForLocalClass, true, null),
+        Arguments.of("MiniaturList", MLAssertions, true, null),
+        Arguments.of("Monitor", emptyList, true, null),
+        Arguments.of("NullArrayInit", emptyList, true, null),
+        Arguments.of("QualifiedStatic", callAssertionForQualifiedStatic, true, null),
+        Arguments.of("Scoping1", emptyList, true, null),
+        Arguments.of("Scoping2", emptyList, true, null),
+        Arguments.of("Simple1", callAssertionForsimple1, true, null),
+        Arguments.of("StaticInitializers", emptyList, true, null),
+        Arguments.of("StaticNesting", callAssertionForStaticNesting, true, null),
+        Arguments.of("Switch1", emptyList, true, null),
+        Arguments.of("Thread1", emptyList, true, null),
+        Arguments.of("TwoClasses", callAssertionForTwoClasses, true, null),
+        Arguments.of("WhileTest1", emptyList, true, null));
+  }
+
+  static Stream<Arguments> javaIRTestsParametersWithPackageName() {
+    return Stream.of(
+        Arguments.of("bugfixes", "DoWhileInCase", emptyList, true, null),
+        Arguments.of("bugfixes", "VarDeclInSwitch", emptyList, true, null),
+        Arguments.of("p", "NonPrimaryTopLevel", emptyList, true, null));
+  }
+
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParameters")
+  public void runJavaIRTests(
+      String java17IRTestName, List<IRAssertion> ca, boolean assertReachable, String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
+    runTest(
+        singleTestSrc(java17IRTestName),
+        rtJar,
+        simpleTestEntryPoint(java17IRTestName),
+        ca,
+        assertReachable,
+        exclusionsFile);
+  }
+
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParametersWithPackageName")
+  public void runJavaIRTestsWithPackageName(
+      String packageName,
+      String testName,
+      List<IRAssertion> callAssertion,
+      boolean assertReachable,
+      String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
+    runTest(
+        singlePkgTestSrc(packageName, testName),
+        rtJar,
+        simplePkgTestEntryPoint(packageName, testName),
+        callAssertion,
+        assertReachable,
+        exclusionsFile);
   }
 
   @Test
   public void testInnerClassA() throws IllegalArgumentException, CancelException, IOException {
     Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+        runTest(
+            singleTestSrc("InnerClassA"),
+            rtJar,
+            simpleTestEntryPoint("InnerClassA"),
+            new ArrayList<>(),
+            true,
+            null);
path: cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
user: login: msridhar
body: There are many call sites now where we pass exactly these arguments, except that the test name is different.  Could we possibly add a new wrapper method for `runTest` that takes a single `String` argument and then calls `runTest` appropriately, and then replace all these other calls with a call to the wrapper method?
created_at: 2025-03-12T15:07:23Z
author_association: MEMBER
diff_hunk: @@ -80,371 +84,411 @@ public JavaIRTests() {
     this(null);
   }
 
-  @Test
-  public void testSimple1() throws IllegalArgumentException, CancelException, IOException {
-
-    List<? extends IRAssertion> assertions =
-        Arrays.asList(
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
-            new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
-            new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
-            EdgeAssertions.make(
-                "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
-            EdgeAssertions.make(
-                "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
-
-    // this needs soure positions to work too
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true, null);
-  }
-
-  @Test
-  public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        List.of(
-            cg -> {
-              final String typeStr = singleInputForTest();
+  static List<? extends IRAssertion> callAssertionForInterfaceTest1 =
+      Arrays.asList(
+          cg -> {
+            final String typeStr = "IFoo";
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              /*
-              assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
-
-              for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
-                assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
-                    .equals(typeStr)
-                    || cls.getName().getClassName().toString().equals("Bar"));
-              }
-              */
-            }),
-        true,
-        null);
-  }
-
-  @Test
-  public void testInterfaceTest1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Arrays.asList(
-            cg -> {
-              final String typeStr = "IFoo";
+            assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
+          },
+          cg -> {
+            final String typeStr = "FooIT1";
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              assertTrue(iClass.isInterface(), "Expected IFoo to be an interface.");
-            },
-            cg -> {
-              final String typeStr = "FooIT1";
+            final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            assertEquals(interfaces.size(), 1, "Expected one single interface.");
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            assertTrue(
+                interfaces.contains(
+                    cg.getClassHierarchy()
+                        .lookupClass(
+                            findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
+                "Expected Foo to implement IFoo");
+          });
 
-              final Collection<? extends IClass> interfaces = iClass.getDirectInterfaces();
+  static List<? extends IRAssertion> callAssertionForInheritance1 =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = "Derived";
 
-              assertEquals(interfaces.size(), 1, "Expected one single interface.");
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              assertTrue(
-                  interfaces.contains(
-                      cg.getClassHierarchy()
-                          .lookupClass(
-                              findOrCreateTypeReference("Source", "IFoo", cg.getClassHierarchy()))),
-                  "Expected Foo to implement IFoo");
-            }),
-        true,
-        null);
-  }
+            final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(derivedClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testInheritance1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = "Derived";
+            final TypeReference baseType =
+                findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
+            final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+            assertEquals(
+                derivedClass.getSuperclass(),
+                baseClass,
+                "Expected 'Base' to be the superclass of 'Derived'");
 
-              final IClass derivedClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(derivedClass, "Could not find class " + typeStr);
+            Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
 
-              final TypeReference baseType =
-                  findOrCreateTypeReference("Source", "Base", cg.getClassHierarchy());
-              final IClass baseClass = cg.getClassHierarchy().lookupClass(baseType);
+            assertTrue(
+                subclasses.contains(derivedClass) && subclasses.contains(baseClass),
+                "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
+          });
 
-              assertEquals(
-                  derivedClass.getSuperclass(),
-                  baseClass,
-                  "Expected 'Base' to be the superclass of 'Derived'");
-
-              Collection<IClass> subclasses = cg.getClassHierarchy().computeSubClasses(baseType);
-
-              assertTrue(
-                  subclasses.contains(derivedClass) && subclasses.contains(baseClass),
-                  "Expected subclasses of 'Base' to be 'Base' and 'Derived'.");
-            }),
-        true,
-        null);
-  }
+  static List<? extends IRAssertion> callAssertionForArrayLiteral1 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[2];
+            assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
+            assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
+          });
+
+  static List<? extends IRAssertion> callAssertionForQualifiedStatic =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+            SSAInstruction s = node.getIR().getInstructions()[4];
+
+            assertTrue(
+                s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
+                "Did not find a getstatic instruction.");
+            final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
+            assertEquals(field.getName().toString(), "value", "Expected a getstatic for 'value'.");
+            assertEquals(
+                field.getDeclaringClass().getName().toString(),
+                "LFooQ",
+                "Expected a getstatic for 'value'.");
+          });
 
-  @Test
-  public void testArray1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            /*
-             * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
-             * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
-             */
-            new IRAssertion() {
+  static List<? extends IRAssertion> callAssertionForArrayLiteral2 =
+      Collections.singletonList(
+          cg -> {
+            MethodReference mref =
+                descriptorToMethodRef(
+                    "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+
+            CGNode node = cg.getNodes(mref).iterator().next();
+
+            final SSAInstruction[] instructions = node.getIR().getInstructions();
+            // test 1
+            {
+              SSAInstruction s1 = instructions[2];
+              if (s1 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 3rd to be a new array instruction.");
+              }
+            }
+            // test 2
+            {
+              SSAInstruction s2 = instructions[3];
+              if (s2 instanceof SSANewInstruction) {
+                assertTrue(
+                    ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
+              } else {
+                fail("Expected 4th to be a new array instruction.");
+              }
+            }
+            // test 3: the last 4 instructions are of the form y[i] = i+1;
+            {
+              final SymbolTable symbolTable = node.getIR().getSymbolTable();
+              for (int i = 4; i <= 7; i++) {
+                assertInstanceOf(
+                    SSAArrayStoreInstruction.class, instructions[i], "Expected only array stores.");
+
+                SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
+
+                assertEquals(
+                    node.getIR().getLocalNames(i, as.getArrayRef())[0],
+                    "y",
+                    "Expected an array store to 'y'.");
+
+                final Integer valueOfArrayIndex =
+                    ((Integer) symbolTable.getConstantValue(as.getIndex()));
+                final Integer valueAssigned = (Integer) symbolTable.getConstantValue(as.getValue());
+
+                assertEquals(
+                    valueAssigned.intValue(),
+                    valueOfArrayIndex + 1,
+                    "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
+              }
+            }
+          });
+
+  static List<EdgeAssertions> edgeAssertionses =
+      Arrays.asList(
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
+          EdgeAssertions.make(
+              "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
+  static List<? extends IRAssertion> callAssertionForArray1 =
+      Collections.singletonList(
+          /*
+           * 'foo' has four array instructions: - 2 SSAArrayLengthInstruction - 1
+           * SSAArrayLoadInstruction - 1 SSAArrayStoreInstruction
+           */
+          new IRAssertion() {
 
-              @Override
-              public void check(CallGraph cg) {
+            @Override
+            public void check(CallGraph cg) {
 
-                MethodReference mref =
-                    descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
+              MethodReference mref =
+                  descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
 
-                int count = 0;
-                CGNode node = cg.getNodes(mref).iterator().next();
-                for (SSAInstruction s : node.getIR().getInstructions()) {
-                  if (isArrayInstruction(s)) {
-                    count++;
-                  }
+              int count = 0;
+              CGNode node = cg.getNodes(mref).iterator().next();
+              for (SSAInstruction s : node.getIR().getInstructions()) {
+                if (isArrayInstruction(s)) {
+                  count++;
                 }
-
-                assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
               }
 
-              private boolean isArrayInstruction(SSAInstruction s) {
-                return s instanceof SSAArrayReferenceInstruction
-                    || s instanceof SSAArrayLengthInstruction;
-              }
-            }),
-        true,
-        null);
-  }
+              assertEquals(count, 4, "Unexpected number of array instructions in 'foo'.");
+            }
 
-  @Test
-  public void testArrayLiteral1() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            private boolean isArrayInstruction(SSAInstruction s) {
+              return s instanceof SSAArrayReferenceInstruction
+                  || s instanceof SSAArrayLengthInstruction;
+            }
+          });
+
+  static List<? extends IRAssertion> callAssertionForsimple1 =
+      Arrays.asList(
+          new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
+          new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28),
+          new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29),
+          EdgeAssertions.make(
+              "Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"),
+          EdgeAssertions.make(
+              "Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));
+
+  static List<? extends IRAssertion> callAssertionForTwoClasses =
+      List.of(
+          cg -> {
+            final String typeStr = singleInputForTest("TwoClasses");
+
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
+
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[2];
-              assertInstanceOf(SSANewInstruction.class, s, "Did not find new array instruction.");
-              assertTrue(((SSANewInstruction) s).getNewSite().getDeclaredType().isArrayType(), "");
-            }),
-        true,
-        null);
-  }
+            /*
+            assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
 
-  @Test
-  public void testArrayLiteral2() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
+              assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
+                  .equals(typeStr)
+                  || cls.getName().getClassName().toString().equals("Bar"));
+            }
+            */
+          });
+  static List<? extends IRAssertion> callAssertionForStaticNesting =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("StaticNesting") + "$WhatsIt";
 
-              CGNode node = cg.getNodes(mref).iterator().next();
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final SSAInstruction[] instructions = node.getIR().getInstructions();
-              // test 1
-              {
-                SSAInstruction s1 = instructions[2];
-                if (s1 instanceof SSANewInstruction) {
-                  assertTrue(
-                      ((SSANewInstruction) s1).getNewSite().getDeclaredType().isArrayType(), "");
-                } else {
-                  fail("Expected 3rd to be a new array instruction.");
-                }
-              }
-              // test 2
-              {
-                SSAInstruction s2 = instructions[3];
-                if (s2 instanceof SSANewInstruction) {
-                  assertTrue(
-                      ((SSANewInstruction) s2).getNewSite().getDeclaredType().isArrayType(), "");
-                } else {
-                  fail("Expected 4th to be a new array instruction.");
-                }
-              }
-              // test 3: the last 4 instructions are of the form y[i] = i+1;
-              {
-                final SymbolTable symbolTable = node.getIR().getSymbolTable();
-                for (int i = 4; i <= 7; i++) {
-                  assertInstanceOf(
-                      SSAArrayStoreInstruction.class,
-                      instructions[i],
-                      "Expected only array stores.");
-
-                  SSAArrayStoreInstruction as = (SSAArrayStoreInstruction) instructions[i];
-
-                  assertEquals(
-                      node.getIR().getLocalNames(i, as.getArrayRef())[0],
-                      "y",
-                      "Expected an array store to 'y'.");
-
-                  final Integer valueOfArrayIndex =
-                      ((Integer) symbolTable.getConstantValue(as.getIndex()));
-                  final Integer valueAssigned =
-                      (Integer) symbolTable.getConstantValue(as.getValue());
-
-                  assertEquals(
-                      valueAssigned.intValue(),
-                      valueOfArrayIndex + 1,
-                      "Expected an array store to 'y' with value " + (valueOfArrayIndex + 1));
-                }
-              }
-            }),
-        true,
-        null);
-  }
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testInheritedField() throws IllegalArgumentException, CancelException, IOException {
-    List<EdgeAssertions> edgeAssertionses =
-        Arrays.asList(
-            EdgeAssertions.make(
-                "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#foo#()V"),
-            EdgeAssertions.make(
-                "Source#InheritedField#main#([Ljava/lang/String;)V", "Source#B#bar#()V"));
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), edgeAssertionses, true, null);
-  }
+            // todo: this fails: assertNotNull("Expected to be enclosed in
+            // 'StaticNesting'.",
+            // ((JavaSourceLoaderImpl.JavaClass)iClass).getEnclosingClass());
+            // todo: is there the concept of CompilationUnit?
 
-  @Test
-  public void testQualifiedStatic() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              MethodReference mref =
-                  descriptorToMethodRef(
-                      "Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
+            /*
+             * {@link JavaCAst2IRTranslator#getEnclosingType} return null for static inner
+             * classes..?
+             */
+          });
 
-              CGNode node = cg.getNodes(mref).iterator().next();
-              SSAInstruction s = node.getIR().getInstructions()[4];
+  static List<? extends IRAssertion> callAssertionForInnerClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("InnerClass");
 
-              assertTrue(
-                  s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic(),
-                  "Did not find a getstatic instruction.");
-              final FieldReference field = ((SSAGetInstruction) s).getDeclaredField();
-              assertEquals(
-                  field.getName().toString(), "value", "Expected a getstatic for 'value'.");
-              assertEquals(
-                  field.getDeclaringClass().getName().toString(),
-                  "LFooQ",
-                  "Expected a getstatic for 'value'.");
-            }),
-        true,
-        null);
-  }
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy());
 
-  @Test
-  public void testStaticNesting() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest() + "$WhatsIt";
-
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
-
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
-
-              // todo: this fails: assertNotNull("Expected to be enclosed in
-              // 'StaticNesting'.",
-              // ((JavaSourceLoaderImpl.JavaClass)iClass).getEnclosingClass());
-              // todo: is there the concept of CompilationUnit?
-
-              /*
-               * {@link JavaCAst2IRTranslator#getEnclosingType} return null for static inner
-               * classes..?
-               */
-            }),
-        true,
-        null);
-  }
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-  @Test
-  public void testCastFromNull() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
-  }
+            assertEquals(
+                ((JavaClass) iClass).getEnclosingClass(),
+                cg.getClassHierarchy()
+                    .lookupClass(
+                        findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy())),
+                "Expected to be enclosed in 'InnerClass'.");
+          });
+
+  static List<? extends IRAssertion> callAssertionForLocalClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("LocalClass");
+            final String localClassStr = "Foo";
+
+            // Observe the descriptor for a class local to a method.
+            final TypeReference mainFooType =
+                findOrCreateTypeReference(
+                    "Source",
+                    typeStr + "/main([Ljava/lang/String;)V/" + localClassStr,
+                    cg.getClassHierarchy());
+
+            // Observe the descriptor for a class local to a method.
+            final IClass mainFooClass = cg.getClassHierarchy().lookupClass(mainFooType);
+            assertNotNull(mainFooClass, "Could not find class " + mainFooType);
+
+            final TypeReference methodFooType =
+                findOrCreateTypeReference(
+                    "Source", typeStr + "/method()V/" + localClassStr, cg.getClassHierarchy());
+
+            final IClass methodFooClass = cg.getClassHierarchy().lookupClass(methodFooType);
+            assertNotNull(methodFooClass, "Could not find class " + methodFooType);
+
+            final IClass localClass =
+                cg.getClassHierarchy()
+                    .lookupClass(
+                        findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy()));
+
+            assertSame(
+                ((JavaClass) methodFooClass).getEnclosingClass(),
+                localClass,
+                "'Foo' is enclosed in 'Local'");
+            // todo: is this failing because 'main' is static?
+            // assertSame("'Foo' is enclosed in 'Local'",
+            // ((JavaSourceLoaderImpl.JavaClass)mainFooClass).getEnclosingClass(),
+            // localClass);
+          });
+  static List<? extends IRAssertion> callAssertionForAnonymousClass =
+      Collections.singletonList(
+          cg -> {
+            final String typeStr = singleInputForTest("AnonymousClass");
 
-  @Test
-  public void testInnerClass() throws IllegalArgumentException, CancelException, IOException {
-    runTest(
-        singleTestSrc(),
-        rtJar,
-        simpleTestEntryPoint(),
-        Collections.singletonList(
-            cg -> {
-              final String typeStr = singleInputForTest();
+            final TypeReference type =
+                findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy());
 
-              final TypeReference type =
-                  findOrCreateTypeReference("Source", typeStr + "$WhatsIt", cg.getClassHierarchy());
+            final IClass iClass = cg.getClassHierarchy().lookupClass(type);
+            assertNotNull(iClass, "Could not find class " + typeStr);
 
-              final IClass iClass = cg.getClassHierarchy().lookupClass(type);
-              assertNotNull(iClass, "Could not find class " + typeStr);
+            // todo what to check?? could not find anything in the APIs for
+            // anonymous
+          });
 
-              assertEquals(
-                  ((JavaClass) iClass).getEnclosingClass(),
-                  cg.getClassHierarchy()
-                      .lookupClass(
-                          findOrCreateTypeReference("Source", typeStr, cg.getClassHierarchy())),
-                  "Expected to be enclosed in 'InnerClass'.");
-            }),
-        true,
-        null);
-  }
+  private static final List<IRAssertion> MLAssertions =
+      Collections.singletonList(
+          new InstructionOperandAssertion(
+              "Source#MiniaturList#main#([Ljava/lang/String;)V",
+              t -> (t instanceof SSAAbstractInvokeInstruction) && t.toString().contains("cons"),
+              1,
+              new int[] {53, 38, 53, 60}));
 
-  @Test
-  public void testNullArrayInit() throws IllegalArgumentException, CancelException, IOException {
-    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+  static Stream<Arguments> javaIRTestsParameters() {
+    return Stream.of(
+        Arguments.of("AnonymousClass", callAssertionForAnonymousClass, true, null),
+        Arguments.of("Array1", callAssertionForArray1, true, null),
+        Arguments.of("ArrayLiteral1", callAssertionForArrayLiteral1, true, null),
+        Arguments.of("ArrayLiteral2", callAssertionForArrayLiteral2, true, null),
+        Arguments.of("Breaks", emptyList, true, null),
+        Arguments.of("CastFromNull", emptyList, true, null),
+        Arguments.of("Casts", emptyList, true, null),
+        Arguments.of("Exception1", emptyList, true, null),
+        Arguments.of("Exception2", emptyList, true, null),
+        Arguments.of("Finally1", emptyList, true, null),
+        Arguments.of("Inheritance1", callAssertionForInheritance1, true, null),
+        Arguments.of("InheritedField", edgeAssertionses, true, null),
+        Arguments.of("InnerClass", callAssertionForInnerClass, true, null),
+        Arguments.of("InterfaceTest1", callAssertionForInterfaceTest1, true, null),
+        Arguments.of("LexicalAccessOfMethodVariablesFromAnonymousClass", emptyList, true, null),
+        Arguments.of("LocalClass", callAssertionForLocalClass, true, null),
+        Arguments.of("MiniaturList", MLAssertions, true, null),
+        Arguments.of("Monitor", emptyList, true, null),
+        Arguments.of("NullArrayInit", emptyList, true, null),
+        Arguments.of("QualifiedStatic", callAssertionForQualifiedStatic, true, null),
+        Arguments.of("Scoping1", emptyList, true, null),
+        Arguments.of("Scoping2", emptyList, true, null),
+        Arguments.of("Simple1", callAssertionForsimple1, true, null),
+        Arguments.of("StaticInitializers", emptyList, true, null),
+        Arguments.of("StaticNesting", callAssertionForStaticNesting, true, null),
+        Arguments.of("Switch1", emptyList, true, null),
+        Arguments.of("Thread1", emptyList, true, null),
+        Arguments.of("TwoClasses", callAssertionForTwoClasses, true, null),
+        Arguments.of("WhileTest1", emptyList, true, null));
+  }
+
+  static Stream<Arguments> javaIRTestsParametersWithPackageName() {
+    return Stream.of(
+        Arguments.of("bugfixes", "DoWhileInCase", emptyList, true, null),
+        Arguments.of("bugfixes", "VarDeclInSwitch", emptyList, true, null),
+        Arguments.of("p", "NonPrimaryTopLevel", emptyList, true, null));
+  }
+
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParameters")
+  public void runJavaIRTests(
+      String java17IRTestName, List<IRAssertion> ca, boolean assertReachable, String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
+    runTest(
+        singleTestSrc(java17IRTestName),
+        rtJar,
+        simpleTestEntryPoint(java17IRTestName),
+        ca,
+        assertReachable,
+        exclusionsFile);
+  }
+
+  @ParameterizedTest
+  @MethodSource("javaIRTestsParametersWithPackageName")
+  public void runJavaIRTestsWithPackageName(
+      String packageName,
+      String testName,
+      List<IRAssertion> callAssertion,
+      boolean assertReachable,
+      String exclusionsFile)
+      throws IllegalArgumentException, CancelException, IOException {
+    runTest(
+        singlePkgTestSrc(packageName, testName),
+        rtJar,
+        simplePkgTestEntryPoint(packageName, testName),
+        callAssertion,
+        assertReachable,
+        exclusionsFile);
   }
 
   @Test
   public void testInnerClassA() throws IllegalArgumentException, CancelException, IOException {
     Pair<CallGraph, CallGraphBuilder<? super InstanceKey>> x =
-        runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<>(), true, null);
+        runTest(
+            singleTestSrc("InnerClassA"),
+            rtJar,
+            simpleTestEntryPoint("InnerClassA"),
+            new ArrayList<>(),
+            true,
+            null);
path: cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/JavaIRTests.java
user: login: jkhaliqi
body: Added in the wrapper, thank you!
created_at: 2025-03-12T23:08:06Z
author_association: CONTRIBUTOR

PR comments:
user: login: github-actions[bot]
created_at: 2025-03-06T21:13:45Z
body: ## Test Results
  827 files  ±  0    827 suites  ±0   4h 20m 54s ⏱️ - 21m 45s
  866 tests +101    849 ✅ +101   17 💤 ±0  0 ❌ ±0 
5 239 runs  ±  0  5 118 ✅ ±  0  121 💤 ±0  0 ❌ ±0 

Results for commit e04fcf9d. ± Comparison against base commit 47220840.

<details>
  <summary>This pull request <b>removes</b> 59 and <b>adds</b> 160 tests. <i>Note that renamed tests count towards both.</i></summary>

```
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testAnnotations()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testAnonGeneNullarySimple()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testAnonymousGenerics()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testBasicsGenerics()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testCocovariant()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testCustomGenericsAndFields()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testEnumSwitch()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testExplicitBoxingTest()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testGenericArrays()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testGenericMemberClasses()
…
```

```
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [10] java15IRTestName=GenericMemberClasses
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [11] java15IRTestName=GenericSuperSink
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [12] java15IRTestName=MoreOverriddenGenerics
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [13] java15IRTestName=NotSoSimpleEnums
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [14] java15IRTestName=OverridesOnePointFour
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [15] java15IRTestName=SimpleEnums
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [16] java15IRTestName=SimpleEnums2
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [17] java15IRTestName=TypeInferencePrimAndStringOp
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [18] java15IRTestName=Varargs
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [19] java15IRTestName=VarargsCovariant
…
```
</details>

[test-results]:data:application/gzip;base64,H4sIAFJt2GcC/03MTQ6DIBCG4asY1l0IMjDTyzQUmYTUnwZh1fTuRaPW5fcwvB/BcQiLuDeo7K0RS4n5MvuSXI7zVEGCAV2pPuftwJhjPZbi/Uqa/vSK7/WXPYVdHKq0J4SU5rRLKtMaBdXRvo4oSIkn7VElD7lEt31t+nkcY65DhFazZ+oNESOgIh1Id84gM1oLMlgPaPkpvj+9DSREEAEAAA==

:recycle: This comment has been updated with latest results.
author_association: NONE
user: login: jkhaliqi
created_at: 2025-03-06T21:37:53Z
body: @msridhar @juliandolby Hey whenever you get a chance could I get review on this, thank you!
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-06T21:45:27Z
body: @jkhaliqi I love it!  Do you have time to take this further?  This is the key function that pulls out the name of the currently-running test:

https://github.com/wala/WALA/blob/90350c797ed8cb23ea165bb7b50da86110d895e4/cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java#L357-L366

I'd love it if we could push this cleanup further so that the function above could just be deleted and everywhere we rely on it we instead use parameterized tests.  I think it would involve a few more changes similar to what you've already done and (hopefully!) deleting a bunch of code.  What do you think?
author_association: MEMBER
user: login: jkhaliqi
created_at: 2025-03-06T22:02:29Z
body: Hey sounds good, and thank you! I'll give that a try and see how far I get
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-07T17:41:23Z
body: @jkhaliqi is this ready for review?
author_association: MEMBER
user: login: jkhaliqi
created_at: 2025-03-07T17:43:40Z
body: @msridhar Yup, I believe this is ready for review, whenever you get a chance, thank you!
author_association: CONTRIBUTOR
user: login: jkhaliqi
created_at: 2025-03-07T18:06:07Z
body: I just changed the JavaIRTests to be alphabetical as well for parametrized tests, but all should be good now!
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-10T18:30:13Z
body: @jkhaliqi can you just add commits to your branch from now on instead of force pushing?  That will make it easier to see what is changing.  I will squash the commits before merging.
author_association: MEMBER
user: login: jkhaliqi
created_at: 2025-03-10T20:10:37Z
body: @msridhar Sounds good, sorry about that!
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-13T01:35:36Z
body: Thanks again for the contribution!  
author_association: MEMBER
user: login: msridhar
created_at: 2025-03-13T01:36:01Z
body: @liblit I think you will need to approve again before this can land
author_association: MEMBER
user: login: jkhaliqi
created_at: 2025-03-13T18:23:51Z
body: @liblit I believe so, is there a way I can double check all the test cases the bot only shows a couple before showing the ...
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-16T23:58:48Z
body: > @liblit I believe so, is there a way I can double check all the test cases the bot only shows a couple before showing the ...

Yeah, this is pretty hard to check based on the [bot comment](https://github.com/wala/WALA/pull/1485#issuecomment-2704954733) which cuts off the output.  Any ideas @liblit?  I can see various artifacts related to the executed tests at the bottom of the [page for the action run](https://github.com/wala/WALA/actions/runs/13841881532?pr=1485) but not clear how to get the full differences from that.
author_association: MEMBER
user: login: liblit
created_at: 2025-03-17T02:15:32Z
body: You could run the tests on your local machine. Test before and after your proposed changes. Presumably each of those will create _some_ kind of artifact you can compare without truncation.
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-17T17:34:50Z
body: > You could run the tests on your local machine. Test before and after your proposed changes. Presumably each of those will create _some_ kind of artifact you can compare without truncation.

Sure, I guess I was wondering if there's an easy way to run whatever code generates the comments on the pull requests, though I guess one could just run `diff` on the relevant files.  
author_association: MEMBER
user: login: msridhar
created_at: 2025-03-17T18:38:05Z
body: In [0db3fc9](https://github.com/wala/WALA/pull/1485/commits/0db3fc988f7a12420c6ac15bdd9ad4778f494e27) I tried bumping up the limit on how many test changes are listed in the comment, using the `test_changes_limit` setting, but it didn't seem to work 😐
author_association: MEMBER
user: login: jkhaliqi
created_at: 2025-03-21T00:47:05Z
body: @liblit Can you explain more on the test and artifact comparison I wasn't able to follow or find the artifacts created after running the test. But I did just run and compare and everything is the same as far as these tests with first number being current change and second one before changes. There's only an increase in one for the tests because the @parameterized part will run but everything else ran the same...
java15irtest -> 22 -> 21
java17 -> 7 -> 6
testcomments-> same
Issue666Test.java -> same
Issue667Test -> same
jlextest -> same 
javairtest -> 37->  37 
syncduplicator -> same
author_association: CONTRIBUTOR
user: login: msridhar
created_at: 2025-03-22T00:08:32Z
body: Thanks again for the contribution @jkhaliqi!
author_association: MEMBER