Added loose parser support to test runner (currently failing for 208/1680).

This commit is contained in:
Ingvar Stepanyan
2014-10-26 17:59:10 +02:00
committed by Marijn Haverbeke
parent d424874cf8
commit 7db211d56a
2 changed files with 17 additions and 7 deletions

View File

@@ -11,7 +11,8 @@
tests.push({code: code, assert: assert, options: options});
};
exports.runTests = function(parse, callback) {
exports.runTests = function(config) {
var parse = config.parse, callback = config.callback;
var comments;
function onComment(block, text, start, end, startLoc, endLoc) {
@@ -32,9 +33,14 @@
try {
comments = [];
if (test.options && !test.options.onComment) test.options.onComment = onComment;
var ast = acorn.parse(test.code, test.options || opts);
if (test.error) callback("fail", test.code,
"Expected error message: " + test.error + "\nBut parsing succeeded.");
var ast = parse(test.code, test.options || opts);
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,