Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-02-08 12:54:39 +0000
committerManoj Palat2019-02-08 14:08:53 +0000
commit9905422dfc86b18bd68711b6506183667724b109 (patch)
tree4bea9bcdeea8a764bf689f9bf6d279eaad4edb07 /org.eclipse.jdt.core.tests.compiler/src
parentd16ad4fd28f95cfb3e1a581cc94a8a4ab680b451 (diff)
downloadeclipse.jdt.core-9905422dfc86b18bd68711b6506183667724b109.tar.gz
eclipse.jdt.core-9905422dfc86b18bd68711b6506183667724b109.tar.xz
eclipse.jdt.core-9905422dfc86b18bd68711b6506183667724b109.zip
Bug 544258 - [12] Warning shown for enum type if the switch expression
does not cover all possible input values Change-Id: I7c96e18c6da5fd264776c8bb1b58af2895b47032
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/CompilerInvocationTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java38
2 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index cbe132bce7..d40a5652d9 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -1175,6 +1175,7 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("SwitchExpressionPreviewDisabled", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("SwitchCaseLabelWithArrowPreviewDisabled", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("SwitchExpressionBreakMissingValue", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("SwitchExpressionMissingEnumConstantCase", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("PreviewFeatureDisabled", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("PreviewFeatureUsed", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("PreviewFeatureNotSupported", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
@@ -2119,6 +2120,7 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("SwitchExpressionPreviewDisabled", SKIP);
expectedProblemAttributes.put("SwitchCaseLabelWithArrowPreviewDisabled", SKIP);
expectedProblemAttributes.put("SwitchExpressionBreakMissingValue", SKIP);
+ expectedProblemAttributes.put("SwitchExpressionMissingEnumConstantCase", SKIP);
expectedProblemAttributes.put("PreviewFeatureDisabled", SKIP);
expectedProblemAttributes.put("PreviewFeatureUsed", SKIP);
expectedProblemAttributes.put("PreviewFeatureNotSupported", SKIP);
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 fbc2ac18e9..d50878833f 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
@@ -1675,4 +1675,42 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
+ public void testBug544258_01() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(Day day) {\n" +
+ " var today = 1;\n" +
+ " today = switch (day) {\n" +
+ " case SATURDAY,SUNDAY :\n" +
+ " today=1;\n" +
+ " break today;\n" +
+ " case MONDAY,TUESDAY,WEDNESDAY,THURSDAY :\n" +
+ " today=2;\n" +
+ " break today;\n" +
+ " };\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " new X().foo(Day.FRIDAY);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "enum Day {\n" +
+ " SUNDAY,\n" +
+ " MONDAY,\n" +
+ " TUESDAY,\n" +
+ " WEDNESDAY,\n" +
+ " THURSDAY,\n" +
+ " FRIDAY,\n" +
+ " SATURDAY\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " today = switch (day) {\n" +
+ " ^^^\n" +
+ "missing enum constant(s) in switch expression as all enum constants are required in case statements if there is no default case.\n" +
+ "----------\n");
+ }
} \ No newline at end of file

Back to the top