< prev index next >

test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8206986
   4  * @summary Verify cases with multiple labels work properly.
   5  * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
   6  * @compile --enable-preview -source 12 MultipleLabelsStatement.java
   7  * @run main/othervm --enable-preview MultipleLabelsStatement
   8  */
   9 
  10 import java.util.Objects;
  11 import java.util.function.Function;
  12 
  13 public class MultipleLabelsStatement {
  14     public static void main(String... args) {
  15         new MultipleLabelsStatement().run();
  16     }
  17 
  18     private void run() {
  19         runTest(this::statement1);
  20     }
  21 
  22     private void runTest(Function<T, String> print) {
  23         check(T.A,  print, "A");
  24         check(T.B,  print, "B-C");
  25         check(T.C,  print, "B-C");
  26         check(T.D,  print, "D");


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8206986
   4  * @summary Verify cases with multiple labels work properly.
   5  * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
   6  * @compile --enable-preview -source 13 MultipleLabelsStatement.java
   7  * @run main/othervm --enable-preview MultipleLabelsStatement
   8  */
   9 
  10 import java.util.Objects;
  11 import java.util.function.Function;
  12 
  13 public class MultipleLabelsStatement {
  14     public static void main(String... args) {
  15         new MultipleLabelsStatement().run();
  16     }
  17 
  18     private void run() {
  19         runTest(this::statement1);
  20     }
  21 
  22     private void runTest(Function<T, String> print) {
  23         check(T.A,  print, "A");
  24         check(T.B,  print, "B-C");
  25         check(T.C,  print, "B-C");
  26         check(T.D,  print, "D");


< prev index next >