Merge acorn 0.12.1 and acorn-babel (formerly "embed acorn" in the original git history).

This commit is contained in:
Logan Smyth
2016-03-14 22:34:29 -07:00
18 changed files with 556 additions and 2394 deletions

View File

@@ -17,43 +17,17 @@
for (var i = 0; i < tests.length; ++i) {
var test = tests[i];
if (config.filter && !config.filter(test)) continue;
var testOpts = test.options || {locations: true};
var expected = {};
if (expected.onComment = testOpts.onComment)
testOpts.onComment = []
if (expected.onToken = testOpts.onToken)
testOpts.onToken = [];
try {
var testOpts = test.options || {locations: true};
var expected = {};
if (expected.onComment = testOpts.onComment) {
testOpts.onComment = []
}
if (expected.onToken = testOpts.onToken) {
testOpts.onToken = [];
}
var ast = parse(test.code, testOpts);
if (test.error) {
if (config.loose) {
callback("ok", test.code);
} else {
callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded.");
}
} else if (test.assert) {
var error = test.assert(ast);
if (error) callback("fail", test.code,
"\n Assertion failed:\n " + error);
else callback("ok", test.code);
} else {
var mis = misMatch(test.ast, ast);
for (var name in expected) {
if (mis) break;
if (expected[name]) {
mis = misMatch(expected[name], testOpts[name]);
testOpts[name] = expected[name];
}
}
if (mis) callback("fail", test.code, mis);
else callback("ok", test.code);
}
} catch(e) {
if (!(e instanceof SyntaxError)) {
throw e;
}
if (!(e instanceof SyntaxError)) throw e;
if (test.error) {
if (e.message == test.error) callback("ok", test.code);
else callback("fail", test.code,
@@ -61,6 +35,27 @@
} else {
callback("error", test.code, e.message || e.toString());
}
continue
}
if (test.error) {
if (config.loose) callback("ok", test.code);
else callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded.");
} else if (test.assert) {
var error = test.assert(ast);
if (error) callback("fail", test.code, "\n Assertion failed:\n " + error);
else callback("ok", test.code);
} else {
var mis = misMatch(test.ast, ast);
for (var name in expected) {
if (mis) break;
if (expected[name]) {
mis = misMatch(expected[name], testOpts[name]);
testOpts[name] = expected[name];
}
}
if (mis) callback("fail", test.code, mis);
else callback("ok", test.code);
}
}
};