Search in sources :

Example 1 with TestErrorReporter

use of org.mozilla.javascript.testing.TestErrorReporter in project hackpad by dropbox.

the class ParserTest method parse.

private AstRoot parse(String string, boolean jsdoc) {
    CompilerEnvirons environment = new CompilerEnvirons();
    TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
    environment.setErrorReporter(testErrorReporter);
    environment.setRecordingComments(true);
    environment.setRecordingLocalJsDocComments(jsdoc);
    Parser p = new Parser(environment, testErrorReporter);
    AstRoot script = p.parse(string, null, 0);
    assertTrue(testErrorReporter.hasEncounteredAllErrors());
    assertTrue(testErrorReporter.hasEncounteredAllWarnings());
    return script;
}
Also used : TestErrorReporter(org.mozilla.javascript.testing.TestErrorReporter) CompilerEnvirons(org.mozilla.javascript.CompilerEnvirons) Parser(org.mozilla.javascript.Parser)

Example 2 with TestErrorReporter

use of org.mozilla.javascript.testing.TestErrorReporter in project hackpad by dropbox.

the class ParserTest method parseAsReader.

private AstRoot parseAsReader(String string) throws IOException {
    CompilerEnvirons environment = new CompilerEnvirons();
    TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
    environment.setErrorReporter(testErrorReporter);
    environment.setRecordingComments(true);
    environment.setRecordingLocalJsDocComments(true);
    Parser p = new Parser(environment, testErrorReporter);
    AstRoot script = p.parse(new StringReader(string), null, 0);
    assertTrue(testErrorReporter.hasEncounteredAllErrors());
    assertTrue(testErrorReporter.hasEncounteredAllWarnings());
    return script;
}
Also used : TestErrorReporter(org.mozilla.javascript.testing.TestErrorReporter) StringReader(java.io.StringReader) CompilerEnvirons(org.mozilla.javascript.CompilerEnvirons) Parser(org.mozilla.javascript.Parser)

Aggregations

CompilerEnvirons (org.mozilla.javascript.CompilerEnvirons)2 Parser (org.mozilla.javascript.Parser)2 TestErrorReporter (org.mozilla.javascript.testing.TestErrorReporter)2 StringReader (java.io.StringReader)1