From 7db211d56a6f2957941e94976a18bd6c19f8e36d Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Sun, 26 Oct 2014 17:59:10 +0200 Subject: [PATCH] Added loose parser support to test runner (currently failing for 208/1680). --- test/driver.js | 14 ++++++++++---- test/run.js | 10 +++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/test/driver.js b/test/driver.js index 539fc00308..8b812bfdca 100644 --- a/test/driver.js +++ b/test/driver.js @@ -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, diff --git a/test/run.js b/test/run.js index 7e84a79464..2fa2c8dbff 100644 --- a/test/run.js +++ b/test/run.js @@ -9,8 +9,12 @@ function report(state, code, message) { } var t0 = +new Date; -var acorn = typeof require == "undefined" ? window.acorn : require("../acorn.js"); -driver.runTests(acorn.parse, report); + +var parse = (typeof require === "undefined" ? window.acorn : require("../acorn.js")).parse; +var parse_dammit = (typeof require === "undefined") ? window.acorn_loose : require("../acorn_loose").parse_dammit; + +driver.runTests({parse: parse, callback: report}); +driver.runTests({parse: parse_dammit, loose: true, callback: report}); console.log(testsRun + " tests run in " + (+new Date - t0) + "ms"); if (failed) { @@ -20,4 +24,4 @@ if (failed) { }); } else { console.log("All passed."); -} \ No newline at end of file +}