test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java
changeset 59021 cfc7bb9a5a92
parent 55306 ea43db53de91
equal deleted inserted replaced
59020:aebd72de84b0 59021:cfc7bb9a5a92
    74         if (!result.isSuccess()) {
    74         if (!result.isSuccess()) {
    75             System.err.printf("Diagnostics: %s%nTemplate: %s%n", diags.errorKeys(), sourceFiles.stream().map(p -> p.snd).collect(toList()));
    75             System.err.printf("Diagnostics: %s%nTemplate: %s%n", diags.errorKeys(), sourceFiles.stream().map(p -> p.snd).collect(toList()));
    76         }
    76         }
    77     }
    77     }
    78 
    78 
    79     private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source",
       
    80                                                Integer.toString(Runtime.version().feature())};
       
    81 
       
    82     private void program(String... constructs) {
    79     private void program(String... constructs) {
    83         String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
    80         String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
    84         for (String c : constructs)
    81         for (String c : constructs)
    85             s = s.replace("#", c);
    82             s = s.replace("#", c);
    86         addSourceFile("C.java", new StringTemplate(s));
    83         addSourceFile("C.java", new StringTemplate(s));
    87     }
    84     }
    88 
    85 
    89     private void assertOK(String... constructs) {
    86     private void assertOK(String... constructs) {
    90         reset();
    87         reset();
    91         addCompileOptions(PREVIEW_OPTIONS);
    88         addCompileOptions();
    92         program(constructs);
    89         program(constructs);
    93         try {
    90         try {
    94             compile();
    91             compile();
    95         }
    92         }
    96         catch (IOException e) {
    93         catch (IOException e) {
    99         assertCompileSucceeded();
    96         assertCompileSucceeded();
   100     }
    97     }
   101 
    98 
   102     private void assertOKWithWarning(String warning, String... constructs) {
    99     private void assertOKWithWarning(String warning, String... constructs) {
   103         reset();
   100         reset();
   104         addCompileOptions(PREVIEW_OPTIONS);
   101         addCompileOptions();
   105         program(constructs);
   102         program(constructs);
   106         try {
   103         try {
   107             compile();
   104             compile();
   108         }
   105         }
   109         catch (IOException e) {
   106         catch (IOException e) {
   112         assertCompileSucceededWithWarning(warning);
   109         assertCompileSucceededWithWarning(warning);
   113     }
   110     }
   114 
   111 
   115     private void assertFail(String expectedDiag, String... constructs) {
   112     private void assertFail(String expectedDiag, String... constructs) {
   116         reset();
   113         reset();
   117         addCompileOptions(PREVIEW_OPTIONS);
   114         addCompileOptions();
   118         program(constructs);
   115         program(constructs);
   119         try {
   116         try {
   120             compile();
   117             compile();
   121         }
   118         }
   122         catch (IOException e) {
   119         catch (IOException e) {