use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class AttachJsdocsTest method parse.
private Node parse(String source, String... warnings) {
TestErrorReporter testErrorReporter = new TestErrorReporter().expectAllWarnings(warnings);
Config config = ParserRunner.createConfig(mode, Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE, Config.RunMode.KEEP_GOING, null, true, StrictMode.SLOPPY);
Node script = ParserRunner.parse(new SimpleSourceFile("input", SourceKind.STRONG), source, config, testErrorReporter).ast;
// verifying that all warnings were seen
testErrorReporter.verifyHasEncounteredAllWarningsAndErrors();
return script;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class JsDocInfoParserTest method parse.
private JSDocInfo parse(String comment, JsDocParsing parseDocumentation, boolean parseFileOverview, String... warnings) {
TestErrorReporter errorReporter = new TestErrorReporter().expectAllWarnings(warnings);
Config config = Config.builder().setExtraAnnotationNames(extraAnnotations).setJsDocParsingMode(parseDocumentation).setSuppressionNames(extraSuppressions).setClosurePrimitiveNames(extraPrimitives).setLanguageMode(LanguageMode.ECMASCRIPT3).setParseInlineSourceMaps(true).setStrictMode(Config.StrictMode.SLOPPY).build();
StaticSourceFile file = new SimpleSourceFile("testcode", SourceKind.STRONG);
Node templateNode = IR.script();
templateNode.setStaticSourceFile(file);
JsDocInfoParser jsdocParser = new JsDocInfoParser(stream(comment), comment, 0, templateNode, config, errorReporter);
jsdocParser.parse();
this.prevLicense = jsdocParser.getLicenseText();
errorReporter.verifyHasEncounteredAllWarningsAndErrors();
final JSDocInfo result;
if (parseFileOverview) {
result = jsdocParser.getFileOverviewJSDocInfo();
} else {
result = jsdocParser.retrieveAndResetParsedJSDocInfo();
}
if (result != null) {
assertThat(result.getTypeNodes()).comparingElementsUsing(transforming(NodeUtil::getSourceName, "has source name that")).doesNotContain(null);
}
return result;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class ParsingUtilTest method parse.
private static Node parse(String source, String... warnings) {
TestErrorReporter testErrorReporter = new TestErrorReporter().expectAllWarnings(warnings);
Config config = ParserRunner.createConfig(LanguageMode.ES_NEXT, Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE, Config.RunMode.KEEP_GOING, null, true, StrictMode.STRICT);
Node script = ParserRunner.parse(new SimpleSourceFile("input", SourceKind.STRONG), source, config, testErrorReporter).ast;
// verifying that all warnings were seen
testErrorReporter.verifyHasEncounteredAllWarningsAndErrors();
return script;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class JsDocInfoParserTest method parseFull.
private Node parseFull(String code, String... warnings) {
TestErrorReporter testErrorReporter = new TestErrorReporter().expectAllWarnings(warnings);
Config config = Config.builder().setExtraAnnotationNames(extraAnnotations).setJsDocParsingMode(JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE).setRunMode(RunMode.KEEP_GOING).setSuppressionNames(extraSuppressions).setLanguageMode(LanguageMode.ECMASCRIPT3).setParseInlineSourceMaps(true).setStrictMode(StrictMode.SLOPPY).build();
ParseResult result = ParserRunner.parse(new SimpleSourceFile("source", SourceKind.STRONG), code, config, testErrorReporter);
testErrorReporter.verifyHasEncounteredAllWarningsAndErrors();
return result.ast;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class CompilerTypeTestCase method setUp.
@Before
public void setUp() throws Exception {
errorReporter = new TestErrorReporter();
initializeNewCompiler(getDefaultOptions());
}
Aggregations