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) { |