Make test runner more generic.

This commit is contained in:
Ingvar Stepanyan 2014-10-26 17:29:51 +02:00 committed by Marijn Haverbeke
parent a18f3d1003
commit d745bd7e32
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,5 @@
(function(exports) {
var tests = [];
var acorn = typeof require == "undefined" ? window.acorn : require("../acorn.js");
exports.test = function(code, ast, options, comments) {
tests.push({code: code, ast: ast, options: options, comments: comments});
@ -12,7 +11,7 @@
tests.push({code: code, assert: assert, options: options});
};
exports.runTests = function(callback) {
exports.runTests = function(parse, callback) {
var comments;
function onComment(block, text, start, end, startLoc, endLoc) {
@ -33,7 +32,7 @@
try {
comments = [];
if (test.options && !test.options.onComment) test.options.onComment = onComment;
var ast = acorn.parse(test.code, test.options || opts);
var ast = parse(test.code, test.options || opts);
if (test.error) callback("fail", test.code,
"Expected error message: " + test.error + "\nBut parsing succeeded.");
else if (test.assert) {

View File

@ -9,7 +9,8 @@ function report(state, code, message) {
}
var t0 = +new Date;
driver.runTests(report);
var acorn = typeof require == "undefined" ? window.acorn : require("../acorn.js");
driver.runTests(acorn.parse, report);
console.log(testsRun + " tests run in " + (+new Date - t0) + "ms");
if (failed) {