Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalat authored Feb 8, 2024
1 parent 8e61439 commit b3d3957
Showing 1 changed file with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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<String, String> 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(
Expand Down

0 comments on commit b3d3957

Please sign in to comment.