From b3d395710bd47f55fa46810bba59e835b2772c6c Mon Sep 17 00:00:00 2001 From: Manoj N Palat Date: Thu, 8 Feb 2024 11:37:48 +0530 Subject: [PATCH] Fixes #933 (#1976) --- .../regression/SwitchPatternTest.java | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 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 8afddd00062..d8990f9879b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2023 IBM Corporation and others. + * Copyright (c) 2021, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,7 +30,7 @@ public class SwitchPatternTest extends AbstractRegressionTest9 { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testIssue1466_02"}; +// TESTS_NAMES = new String[] { "testBug575571_1"}; } private static String previewLevel = "21"; @@ -104,7 +104,7 @@ protected void runWarningTest(String[] testFiles, String expectedCompilerLog, runner.testFiles = testFiles; runner.expectedCompilerLog = expectedCompilerLog; runner.customOptions = customOptions; - runner.vmArguments = new String[] {""}; + runner.vmArguments = new String[] {}; runner.runWarningTest(); } @@ -3752,32 +3752,30 @@ public void testBug575051_2() { }, ""); } - // Test we do report illegal fall-through to pattern - public void testBug575051_3() { - runNegativeTest( - new String[] { - "X.java", - "public class X {\n" + - " public void foo(Object o) {\n" + - " switch (o) {\n" + - " default : \n" + - " case String s :\n" + - " System.out.println();\n" + - " break;\n" + - " }\n" + - " }\n" + - " public static void main(String[] args) {\n" + - " (new X()).foo(null);\n" + - " }\n" + - "}", - }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " case String s :\n" + - " ^^^^^^^^\n" + - "This case label is dominated by one of the preceding case labels\n" + - "----------\n", - ""); + public void testBug575571_1() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportMissingDefaultCase, CompilerOptions.WARNING); + runWarningTest( + new String[] { + "X.java", + "public class X {\n" + + " public void foo(Color o) {\n" + + " switch (o) {\n" + + " case Blue:\n" + + " break;\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {}\n" + + "}\n" + + "enum Color { Blue; }\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " switch (o) {\n" + + " ^\n" + + "The switch over the enum type Color should have a default case\n" + + "----------\n", + options); } public void testBug575571_2() { runNegativeTest(