Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2021-08-04 12:48:29 +0000
committerJay Arthanareeswaran2021-08-05 05:46:07 +0000
commitdc227d950192638573b7cf5752e47a9539a501d0 (patch)
treeb6aef1126175f48acffa551af2d83541bfef7cb6
parent9506e05f94b4d894c32081180cb7c3b7629b5ebd (diff)
downloadeclipse.jdt.core-dc227d950192638573b7cf5752e47a9539a501d0.tar.gz
eclipse.jdt.core-dc227d950192638573b7cf5752e47a9539a501d0.tar.xz
eclipse.jdt.core-dc227d950192638573b7cf5752e47a9539a501d0.zip
Bug 575053 - [17]14.11.3 Execution of a switch StatementY20210805-0800P20210805-0900P20210805-0800P20210805-0320
Change-Id: Ie5bcf0597c19087f74302dfdedf050ed02bb71de Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/183688 Tested-by: JDT Bot <jdt-bot@eclipse.org>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java54
1 files changed, 53 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java
index aa65019bbe..f28327299d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java
@@ -2758,4 +2758,56 @@ public class SwitchPatternTest extends AbstractRegressionTest9 {
"Switch case cannot have both a total pattern and default label\n" +
"----------\n");
}
-} \ No newline at end of file
+ public void testBug575053_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(String o) {\n" +
+ " switch (o) {\n" +
+ " case String s && s.length() > 0 -> {}\n" +
+ " default -> {}\n" +
+ " } \n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " try{\n" +
+ " (new X()).foo(null);\n" +
+ " } catch(Exception t) {\n" +
+ " t.printStackTrace();\n" +
+ " }\n" +
+ " }\n"+
+ "}",
+ },
+ "",
+ "java.lang.NullPointerException\n" +
+ " at java.base/java.util.Objects.requireNonNull(Objects.java:208)\n" +
+ " at X.foo(X.java:3)\n" +
+ " at X.main(X.java:10)");
+ }
+ public void testBug575053_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(Object o) {\n" +
+ " switch (o) {\n" +
+ " case String s -> {}\n" +
+ " default -> {}\n" +
+ " } \n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " try{\n" +
+ " (new X()).foo(null);\n" +
+ " } catch(Exception t) {\n" +
+ " t.printStackTrace();\n" +
+ " }\n" +
+ " }\n"+
+ "}",
+ },
+ "",
+ "java.lang.NullPointerException\n" +
+ " at java.base/java.util.Objects.requireNonNull(Objects.java:208)\n" +
+ " at X.foo(X.java:3)\n" +
+ " at X.main(X.java:10)");
+ }
+}

Back to the top