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(null, 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", false), source, config, testErrorReporter).ast;
// verifying that all warnings were seen
testErrorReporter.assertHasEncounteredAllErrors();
testErrorReporter.assertHasEncounteredAllWarnings();
return script;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class TypeTransformationTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
errorReporter = new TestErrorReporter(null, null);
initRecordTypeTests();
typeVars = new ImmutableMap.Builder<String, JSType>().put("S", STRING_TYPE).put("N", NUMBER_TYPE).put("B", BOOLEAN_TYPE).put("BOT", NO_TYPE).put("TOP", ALL_TYPE).put("UNK", UNKNOWN_TYPE).put("CHKUNK", CHECKED_UNKNOWN_TYPE).put("SO", STRING_OBJECT_TYPE).put("NO", NUMBER_OBJECT_TYPE).put("BO", BOOLEAN_OBJECT_TYPE).put("NULL", NULL_TYPE).put("OBJ", OBJECT_TYPE).put("UNDEF", VOID_TYPE).put("ARR", ARRAY_TYPE).put("ARRNUM", type(ARRAY_TYPE, NUMBER_TYPE)).put("REC", recordTypeTest).put("NESTEDREC", nestedRecordTypeTest).put("ASYNCH", asynchRecord).build();
nameVars = new ImmutableMap.Builder<String, String>().put("s", "string").put("n", "number").put("b", "boolean").build();
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class ParserTest method doParse.
private ParserRunner.ParseResult doParse(String string, String... warnings) {
TestErrorReporter testErrorReporter = new TestErrorReporter(null, warnings);
StaticSourceFile file = new SimpleSourceFile("input", false);
ParserRunner.ParseResult result = ParserRunner.parse(file, string, createConfig(), testErrorReporter);
// check expected features if specified
assertFS(result.features).contains(expectedFeatures);
// verifying that all warnings were seen
testErrorReporter.assertHasEncounteredAllErrors();
testErrorReporter.assertHasEncounteredAllWarnings();
return result;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class ParserTest method parseError.
/**
* Verify that the given code has the given parse errors.
* @return If in IDE mode, returns a partial tree.
*/
private Node parseError(String source, String... errors) {
TestErrorReporter testErrorReporter = new TestErrorReporter(errors, null);
ParseResult result = ParserRunner.parse(new SimpleSourceFile("input", false), source, createConfig(), testErrorReporter);
Node script = result.ast;
// check expected features if specified
assertFS(result.features).contains(expectedFeatures);
// verifying that all errors were seen
testErrorReporter.assertHasEncounteredAllErrors();
testErrorReporter.assertHasEncounteredAllWarnings();
return script;
}
use of com.google.javascript.rhino.testing.TestErrorReporter in project closure-compiler by google.
the class NodeTest method testCheckTreeTypeAwareEqualsSame.
public void testCheckTreeTypeAwareEqualsSame() {
TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
JSTypeRegistry registry = new JSTypeRegistry(testErrorReporter);
Node node1 = Node.newString(Token.NAME, "f");
node1.setJSType(registry.getNativeType(JSTypeNative.NUMBER_TYPE));
Node node2 = Node.newString(Token.NAME, "f");
node2.setJSType(registry.getNativeType(JSTypeNative.NUMBER_TYPE));
assertTrue(node1.isEquivalentToTyped(node2));
}
Aggregations