< prev index next >

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

Print this page
rev 51104 : imported patch switch


 161     // After the suite is done, dump any errors to output
 162     public void dumpErrors() {
 163         if (!suiteErrors.isEmpty())
 164             System.err.println("Errors found in test suite: " + suiteErrors);
 165     }
 166 
 167     /**
 168      * Get a description of this test case; since test cases may be combinatorially
 169      * generated, this should include all information needed to describe the test case
 170      */
 171     protected String getTestCaseDescription() {
 172         return this.toString();
 173     }
 174 
 175     /** Assert that all previous calls to compile() succeeded */
 176     protected void assertCompileSucceeded() {
 177         if (diags.errorsFound())
 178             fail("Expected successful compilation");
 179     }
 180 








 181     /**
 182      * If the provided boolean is true, assert all previous compiles succeeded,
 183      * otherwise assert that a compile failed.
 184      * */
 185     protected void assertCompileSucceededIff(boolean b) {
 186         if (b)
 187             assertCompileSucceeded();
 188         else
 189             assertCompileFailed();
 190     }
 191 
 192     /** Assert that a previous call to compile() failed */
 193     protected void assertCompileFailed() {
 194         if (!diags.errorsFound())
 195             fail("Expected failed compilation");
 196     }
 197 
 198     /** Assert that a previous call to compile() failed with a specific error key */
 199     protected void assertCompileFailed(String message) {








 200         if (!diags.errorsFound())
 201             fail("Expected failed compilation: " + message);





 202     }
 203 
 204     /** Assert that a previous call to compile() failed with all of the specified error keys */
 205     protected void assertCompileErrors(String... keys) {
 206         if (!diags.errorsFound())
 207             fail("Expected failed compilation");
 208         for (String k : keys)
 209             if (!diags.containsErrorKey(k))
 210                 fail("Expected compilation error " + k);
 211     }
 212 
 213     /** Convert an object, which may be a Template or a String, into a Template */
 214     protected Template asTemplate(Object o) {
 215         if (o instanceof Template)
 216             return (Template) o;
 217         else if (o instanceof String)
 218             return new StringTemplate((String) o);
 219         else
 220             return new StringTemplate(o.toString());
 221     }




 161     // After the suite is done, dump any errors to output
 162     public void dumpErrors() {
 163         if (!suiteErrors.isEmpty())
 164             System.err.println("Errors found in test suite: " + suiteErrors);
 165     }
 166 
 167     /**
 168      * Get a description of this test case; since test cases may be combinatorially
 169      * generated, this should include all information needed to describe the test case
 170      */
 171     protected String getTestCaseDescription() {
 172         return this.toString();
 173     }
 174 
 175     /** Assert that all previous calls to compile() succeeded */
 176     protected void assertCompileSucceeded() {
 177         if (diags.errorsFound())
 178             fail("Expected successful compilation");
 179     }
 180 
 181     /** Assert that all previous calls to compile() succeeded */
 182     protected void assertCompileSucceededWithWarning(String warning) {
 183         if (diags.errorsFound())
 184             fail("Expected successful compilation");
 185         if (!diags.containsWarningKey(warning))
 186             fail("Expected compilation warning " + warning);
 187     }
 188 
 189     /**
 190      * If the provided boolean is true, assert all previous compiles succeeded,
 191      * otherwise assert that a compile failed.
 192      * */
 193     protected void assertCompileSucceededIff(boolean b) {
 194         if (b)
 195             assertCompileSucceeded();
 196         else
 197             assertCompileFailed();
 198     }
 199 
 200     /** Assert that a previous call to compile() failed */
 201     protected void assertCompileFailed() {
 202         if (!diags.errorsFound())
 203             fail("Expected failed compilation");
 204     }
 205 
 206     /** Assert that a previous call to compile() failed with a specific error key */
 207     protected void assertCompileFailed(String key) {
 208         if (!diags.errorsFound())
 209             fail("Expected failed compilation: " + key);
 210         if (!diags.containsErrorKey(key))
 211             fail("Expected compilation error " + key);
 212     }
 213 
 214     /** Assert that a previous call to compile() failed with a specific error key */
 215     protected void assertCompileFailedOneOf(String... keys) {
 216         if (!diags.errorsFound())
 217             fail("Expected failed compilation with one of: " + Arrays.asList(keys));
 218         boolean found = false;
 219         for (String k : keys)
 220             if (diags.containsErrorKey(k))
 221                 found = true;
 222         fail(String.format("Expected compilation error with one of %s, found %s", Arrays.asList(keys), diags.keys()));
 223     }
 224 
 225     /** Assert that a previous call to compile() failed with all of the specified error keys */
 226     protected void assertCompileErrors(String... keys) {
 227         if (!diags.errorsFound())
 228             fail("Expected failed compilation");
 229         for (String k : keys)
 230             if (!diags.containsErrorKey(k))
 231                 fail("Expected compilation error " + k);
 232     }
 233 
 234     /** Convert an object, which may be a Template or a String, into a Template */
 235     protected Template asTemplate(Object o) {
 236         if (o instanceof Template)
 237             return (Template) o;
 238         else if (o instanceof String)
 239             return new StringTemplate((String) o);
 240         else
 241             return new StringTemplate(o.toString());
 242     }


< prev index next >