Comparing version 0.0.1 to 0.1.0
@@ -6,3 +6,3 @@ { | ||
"main": "acorn.js", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"engines": {"node": ">=0.4.0"}, | ||
@@ -9,0 +9,0 @@ "maintainers": [{"name": "Marijn Haverbeke", |
@@ -11,5 +11,8 @@ (function(exports) { | ||
}; | ||
exports.testAssert = function(code, assert, options) { | ||
tests.push({code: code, assert: assert, options: options}); | ||
}; | ||
exports.runTests = function(callback) { | ||
var opts = {linePositions: true}; | ||
var opts = {locations: true}; | ||
for (var i = 0; i < tests.length; ++i) { | ||
@@ -21,3 +24,8 @@ var test = tests[i]; | ||
"Expected error message: " + test.error + "\nBut parsing succeeded."); | ||
else { | ||
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); | ||
@@ -63,2 +71,25 @@ if (!mis) callback("ok", test.code); | ||
} | ||
function mangle(ast) { | ||
if (typeof ast != "object" || !ast) return; | ||
if (ast.slice) { | ||
for (var i = 0; i < ast.length; ++i) mangle(ast[i]); | ||
} else { | ||
var loc = ast.start && ast.end && {start: ast.start, end: ast.end}; | ||
if (loc) { delete ast.start; delete ast.end; } | ||
for (var name in ast) if (ast.hasOwnProperty(name)) mangle(ast[name]); | ||
if (loc) ast.loc = loc; | ||
} | ||
} | ||
exports.printTests = function() { | ||
var out = ""; | ||
for (var i = 0; i < tests.length; ++i) { | ||
if (tests[i].error) continue; | ||
mangle(tests[i].ast); | ||
out += "test(" + JSON.stringify(tests[i].code) + ", " + JSON.stringify(tests[i].ast, null, 2) + ");\n\n"; | ||
} | ||
document.body.innerHTML = ""; | ||
document.body.appendChild(document.createElement("pre")).appendChild(document.createTextNode(out)); | ||
}; | ||
})(typeof exports == "undefined" ? window : exports); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1624660
22
48804
2