Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-03-18 05:18:06 -0400
committerManoj Palat2019-03-18 05:18:06 -0400
commitb0ea2537d4d56aca29790d69668f4176dbb83a83 (patch)
tree71a9f06f1eb4dfcdd7aa972b713d41829644a78a
parente68c447eb7a2a4b0a697b62778de82297fe800c4 (diff)
downloadeclipse.jdt.core-b0ea2537d4d56aca29790d69668f4176dbb83a83.tar.gz
eclipse.jdt.core-b0ea2537d4d56aca29790d69668f4176dbb83a83.tar.xz
eclipse.jdt.core-b0ea2537d4d56aca29790d69668f4176dbb83a83.zip
Test case for bug 545333: [12] result expression absence error in ecj
while javac compiles
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java33
1 files changed, 33 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 76b00319c9..4413510866 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
@@ -2234,4 +2234,37 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
"Type mismatch: cannot convert from Object to boolean\n" +
"----------\n");
}
+ public void testBug545333() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int i) throws MyException {\n"+
+ " int v = switch (i) {\n"+
+ " default -> throw new MyException();\n"+
+ " };\n"+
+ " return v;\n"+
+ " }\n"+
+ " public static void main(String argv[]) {\n"+
+ " try {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " } catch (MyException e) {\n"+
+ " System.out.println(\"Exception thrown as expected\");\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class MyException extends Exception {\n"+
+ " private static final long serialVersionUID = 3461899582505930473L; \n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " int v = switch (i) {\n" +
+ " default -> throw new MyException();\n" +
+ " };\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "A switch expression should have at least one result expression\n" +
+ "----------\n");
+ }
} \ No newline at end of file

Back to the top