Add test ensuring synthetic methods are visible in stacktrace and debug

Bug: 131726995
Change-Id: Ib774a2485fcb791f9af15583b39c0edcdba7460a
diff --git a/src/test/java/com/android/tools/r8/debug/JvmSyntheticTest.java b/src/test/java/com/android/tools/r8/debug/JvmSyntheticTest.java
new file mode 100644
index 0000000..0047a77
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/JvmSyntheticTest.java
@@ -0,0 +1,22 @@
+package com.android.tools.r8.debug;
+
+public class JvmSyntheticTest {
+
+  public static class A {
+
+    private static void foo() {
+      throw new RuntimeException("Foo");
+    }
+  }
+
+  public static class Runner {
+
+    public static void main(String[] args) {
+      try {
+        A.foo();
+      } catch (Exception ex) {
+        ex.printStackTrace(System.out);
+      }
+    }
+  }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/JvmSyntheticTestRunner.java b/src/test/java/com/android/tools/r8/debug/JvmSyntheticTestRunner.java
new file mode 100644
index 0000000..e3f0660
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/JvmSyntheticTestRunner.java
@@ -0,0 +1,70 @@
+package com.android.tools.r8.debug;
+
+import static com.android.tools.r8.references.Reference.methodFromMethod;
+import static org.hamcrest.CoreMatchers.containsString;
+
+import com.android.tools.r8.CompilationFailedException;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.JvmSyntheticTest.A;
+import com.android.tools.r8.debug.JvmSyntheticTest.Runner;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class JvmSyntheticTestRunner extends DebugTestBase {
+
+  public static final Class<?> CLASS = Runner.class;
+
+  @Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    return getTestParameters().withCfRuntimes().build();
+  }
+
+  private TestParameters parameters;
+
+  public JvmSyntheticTestRunner(TestParameters parameters) {
+    this.parameters = parameters;
+  }
+
+  @Test
+  public void testStacktrace() throws ExecutionException, CompilationFailedException, IOException {
+    testForJvm()
+        .addProgramClasses(A.class, CLASS)
+        .run(parameters.getRuntime(), CLASS)
+        .assertSuccessWithOutputThatMatches(
+            containsString("at com.android.tools.r8.debug.JvmSyntheticTest$A.access$000"));
+  }
+
+  @Test
+  public void testDebug() throws Throwable {
+    DebugTestConfig debugTestConfig = testForJvm().addProgramClasses(A.class, CLASS).debugConfig();
+    runDebugTest(
+        debugTestConfig,
+        CLASS,
+        breakpoint(methodFromMethod(CLASS.getMethod("main", String[].class))),
+        run(),
+        checkMethod(CLASS.getTypeName(), "main"),
+        stepInto(),
+        checkMethod(A.class.getTypeName(), "access$000"),
+        run());
+  }
+
+  @Test
+  public void testDebugIntelliJ() throws Throwable {
+    DebugTestConfig debugTestConfig = testForJvm().addProgramClasses(A.class, CLASS).debugConfig();
+    runDebugTest(
+        debugTestConfig,
+        CLASS,
+        breakpoint(methodFromMethod(CLASS.getMethod("main", String[].class))),
+        run(),
+        checkMethod(CLASS.getTypeName(), "main"),
+        stepInto(INTELLIJ_FILTER),
+        checkMethod(A.class.getTypeName(), "foo"),
+        run());
+  }
+}