< prev index next >

test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java

Print this page

137         if (diags.errorsFound())
138             fail("Expected successful compilation");
139     }
140 
141     /** Assert that all previous calls to compile() succeeded, also accepts a diagnostics consumer */
142     protected void assertCompileSucceeded(Consumer<Diagnostic<?>> diagConsumer) {
143         if (diags.errorsFound())
144             fail("Expected successful compilation");
145         diags.getAllDiags().stream().forEach(diagConsumer);
146     }
147 
148     /** Assert that all previous calls to compile() succeeded */
149     protected void assertCompileSucceededWithWarning(String warning) {
150         if (diags.errorsFound())
151             fail("Expected successful compilation");
152         if (!diags.containsWarningKey(warning)) {
153             fail(String.format("Expected compilation warning with %s, found %s", warning, diags.keys()));
154         }
155     }
156 








157     /**
158      * If the provided boolean is true, assert all previous compiles succeeded,
159      * otherwise assert that a compile failed.
160      * */
161     protected void assertCompileSucceededIff(boolean b) {
162         if (b)
163             assertCompileSucceeded();
164         else
165             assertCompileFailed();
166     }
167 
168     /** Assert that a previous call to compile() failed */
169     protected void assertCompileFailed() {
170         if (!diags.errorsFound())
171             fail("Expected failed compilation");
172     }
173 
174     /** Assert that a previous call to compile() failed with a specific error key */
175     protected void assertCompileFailed(String key) {
176         if (!diags.errorsFound())

137         if (diags.errorsFound())
138             fail("Expected successful compilation");
139     }
140 
141     /** Assert that all previous calls to compile() succeeded, also accepts a diagnostics consumer */
142     protected void assertCompileSucceeded(Consumer<Diagnostic<?>> diagConsumer) {
143         if (diags.errorsFound())
144             fail("Expected successful compilation");
145         diags.getAllDiags().stream().forEach(diagConsumer);
146     }
147 
148     /** Assert that all previous calls to compile() succeeded */
149     protected void assertCompileSucceededWithWarning(String warning) {
150         if (diags.errorsFound())
151             fail("Expected successful compilation");
152         if (!diags.containsWarningKey(warning)) {
153             fail(String.format("Expected compilation warning with %s, found %s", warning, diags.keys()));
154         }
155     }
156 
157     protected void assertCompileSucceededWithWarning(String warning, int numberOfWarnings) {
158         if (diags.errorsFound())
159             fail("Expected successful compilation");
160         if (!diags.containsWarningKey(warning, numberOfWarnings)) {
161             fail(String.format("Expected compilation warning with %s, found %s", warning, diags.keys()));
162         }
163     }
164 
165     /**
166      * If the provided boolean is true, assert all previous compiles succeeded,
167      * otherwise assert that a compile failed.
168      * */
169     protected void assertCompileSucceededIff(boolean b) {
170         if (b)
171             assertCompileSucceeded();
172         else
173             assertCompileFailed();
174     }
175 
176     /** Assert that a previous call to compile() failed */
177     protected void assertCompileFailed() {
178         if (!diags.errorsFound())
179             fail("Expected failed compilation");
180     }
181 
182     /** Assert that a previous call to compile() failed with a specific error key */
183     protected void assertCompileFailed(String key) {
184         if (!diags.errorsFound())
< prev index next >