Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thomann2019-02-08 21:43:56 +0000
committerManoj Palat2019-02-08 21:43:56 +0000
commitbc14b2cd549a482f648d983b3db10e6125179239 (patch)
tree111df0ca40cc3d7fe2d5c641ce2a9f0831aebbea /org.eclipse.jdt.core.tests.compiler/src
parent9905422dfc86b18bd68711b6506183667724b109 (diff)
downloadeclipse.jdt.core-bc14b2cd549a482f648d983b3db10e6125179239.tar.gz
eclipse.jdt.core-bc14b2cd549a482f648d983b3db10e6125179239.tar.xz
eclipse.jdt.core-bc14b2cd549a482f648d983b3db10e6125179239.zip
Bug 544254 [12][codegen] Switch Expressions - Inconsistent stackmap
frames at branch target error and Bug 544253 - [12][codegen] Switch Expressions - Multiple codegen errors Change-Id: I7211d9737c7e26365a7250c68e725a9cce15e072
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
index d50878833f..cfabad7ae0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
@@ -1713,4 +1713,101 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"missing enum constant(s) in switch expression as all enum constants are required in case statements if there is no default case.\n" +
"----------\n");
}
+ public void testBug544253() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(int i ) {\n" +
+ " boolean b = switch (i) {\n" +
+ " case 0 -> i == 1;\n" +
+ " default -> true;\n" +
+ " };\n" +
+ " System.out.println( b ? \" true\" : \"false\");\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " new X().foo(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "false",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ public void testBug544254() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String s) {\n" +
+ " try {\n" +
+ " int i = switch (s) {\n" +
+ " case \"hello\" -> 0;\n" +
+ " default -> 2;\n" +
+ " };\n" +
+ " } finally {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(\"hello\");\n" +
+ " }\n" +
+ "}"
+ },
+ "hello",
+ null,
+ new String[] {"--enable-preview"});
+ }
+ public void testBug544254_2() {
+ Map<String, String> customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String s) {\n" +
+ " try {\n" +
+ " int i = switch (s) {\n" +
+ " case \"hello\" -> 0;\n" +
+ " default -> 2;\n" +
+ " };\n" +
+ " } finally {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(\"hello\");\n" +
+ " }\n" +
+ "}"
+ },
+ "hello",
+ customOptions,
+ new String[] {"--enable-preview"});
+ }
+ public void testBug544254_3() {
+ Map<String, String> customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String s) {\n" +
+ " try {\n" +
+ " long l = switch (s) {\n" +
+ " case \"hello\" -> 0;\n" +
+ " default -> 2;\n" +
+ " };\n" +
+ " } finally {\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(\"hello\");\n" +
+ " }\n" +
+ "}"
+ },
+ "hello",
+ customOptions,
+ new String[] {"--enable-preview"});
+ }
} \ No newline at end of file

Back to the top