Move static enum merging test to jdk17
Change-Id: Ie4dc2006ab9244774aacff72c5d070368778361c
diff --git a/src/test/examplesJava17/enumStatic/EnumStaticMain.java b/src/test/examplesJava17/enumStatic/EnumStaticMain.java
deleted file mode 100644
index 6e79499..0000000
--- a/src/test/examplesJava17/enumStatic/EnumStaticMain.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package enumStatic;
-
-public class EnumStaticMain {
-
- enum EnumStatic {
- A,
- B {
- static int i = 17;
-
- static void print() {
- System.out.println("-" + i);
- }
-
- public void virtualPrint() {
- print();
- }
- };
-
- public void virtualPrint() {}
- }
-
- public static void main(String[] args) throws Throwable {
- EnumStatic.B.virtualPrint();
- }
-}
diff --git a/src/test/java/com/android/tools/r8/enumunboxing/enummerging/StaticEnumMergingTest.java b/src/test/examplesJava17/enumStatic/StaticEnumMergingTest.java
similarity index 65%
rename from src/test/java/com/android/tools/r8/enumunboxing/enummerging/StaticEnumMergingTest.java
rename to src/test/examplesJava17/enumStatic/StaticEnumMergingTest.java
index 4c5e8bc..19f4f8c 100644
--- a/src/test/java/com/android/tools/r8/enumunboxing/enummerging/StaticEnumMergingTest.java
+++ b/src/test/examplesJava17/enumStatic/StaticEnumMergingTest.java
@@ -1,16 +1,11 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+package enumStatic; // Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.enumunboxing.enummerging;
-
-import static com.android.tools.r8.utils.FileUtils.JAR_EXTENSION;
import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.enumunboxing.EnumUnboxingTestBase;
import com.android.tools.r8.utils.StringUtils;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -20,18 +15,14 @@
@RunWith(Parameterized.class)
public class StaticEnumMergingTest extends EnumUnboxingTestBase {
- private static final Path JDK17_JAR =
- Paths.get(ToolHelper.TESTS_BUILD_DIR, "examplesJava17").resolve("enumStatic" + JAR_EXTENSION);
private static final String EXPECTED_RESULT = StringUtils.lines("-17");
- private static final String MAIN = "enumStatic.EnumStaticMain";
-
private final TestParameters parameters;
private final boolean enumValueOptimization;
private final EnumKeepRules enumKeepRules;
@Parameters(name = "{0} valueOpt: {1} keep: {2}")
public static List<Object[]> data() {
- return enumUnboxingTestParameters();
+ return EnumUnboxingTestBase.enumUnboxingTestParameters();
}
public StaticEnumMergingTest(
@@ -44,14 +35,36 @@
@Test
public void testEnumUnboxing() throws Exception {
testForR8(parameters.getBackend())
- .addProgramFiles(JDK17_JAR)
- .addKeepMainRule(MAIN)
+ .addInnerClassesAndStrippedOuter(getClass())
+ .addKeepMainRule(EnumStaticMain.class)
.addKeepRules(enumKeepRules.getKeepRules())
.addOptionsModification(opt -> enableEnumOptions(opt, enumValueOptimization))
- .addOptionsModification(opt -> opt.testing.enableEnumUnboxingDebugLogs = true)
.setMinApi(parameters)
- .allowDiagnosticInfoMessages()
- .run(parameters.getRuntime(), MAIN)
+ .run(parameters.getRuntime(), EnumStaticMain.class)
.assertSuccessWithOutput(EXPECTED_RESULT);
}
+
+ public class EnumStaticMain {
+
+ enum EnumStatic {
+ A,
+ B {
+ static int i = 17;
+
+ static void print() {
+ System.out.println("-" + i);
+ }
+
+ public void virtualPrint() {
+ print();
+ }
+ };
+
+ public void virtualPrint() {}
+ }
+
+ public static void main(String[] args) throws Throwable {
+ EnumStatic.B.virtualPrint();
+ }
+ }
}
diff --git a/src/test/java/com/android/tools/r8/enumunboxing/kotlin/SimpleKotlinEnumUnboxingTest.java b/src/test/java/com/android/tools/r8/enumunboxing/kotlin/SimpleKotlinEnumUnboxingTest.java
index 1fdd6cb..ae75dfd 100644
--- a/src/test/java/com/android/tools/r8/enumunboxing/kotlin/SimpleKotlinEnumUnboxingTest.java
+++ b/src/test/java/com/android/tools/r8/enumunboxing/kotlin/SimpleKotlinEnumUnboxingTest.java
@@ -4,9 +4,7 @@
package com.android.tools.r8.enumunboxing.kotlin;
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticMessage;
import static com.android.tools.r8.KotlinTestBase.getCompileMemoizer;
-import static org.hamcrest.core.StringContains.containsString;
import com.android.tools.r8.KotlinTestBase.KotlinCompileMemoizer;
import com.android.tools.r8.KotlinTestParameters;
diff --git a/src/test/java/com/android/tools/r8/enumunboxing/EnumUnboxingTestBase.java b/src/test/testbase/java/com/android/tools/r8/enumunboxing/EnumUnboxingTestBase.java
similarity index 100%
rename from src/test/java/com/android/tools/r8/enumunboxing/EnumUnboxingTestBase.java
rename to src/test/testbase/java/com/android/tools/r8/enumunboxing/EnumUnboxingTestBase.java