[Pkg-javascript-commits] [node-acorn-jsx] 313/484: Added loose parser support to test runner (currently failing for 208/1680).
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:48 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 7db211d56a6f2957941e94976a18bd6c19f8e36d
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Sun Oct 26 17:59:10 2014 +0200
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 539fc00..8b812bf 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 7e84a79..2fa2c8d 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
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list