flow-parser
Advanced tools
Comparing version 0.7.0 to 0.21.0
{ | ||
"name": "flow-parser", | ||
"version": "0.7.0", | ||
"version": "0.21.0", | ||
"license": "BSD-3-Clause", | ||
@@ -19,6 +19,6 @@ "description": "JavaScript parser written in OCaml. Produces SpiderMonkey AST", | ||
"devDependencies": { | ||
"esprima-fb": "15001.1.0-dev-harmony-fb" | ||
"esprima-fb": "15001.1001.0-dev-harmony-fb" | ||
}, | ||
"dependencies": { | ||
"ast-types": "0.8.4", | ||
"ast-types": "0.8.14", | ||
"colors": ">=0.6.2", | ||
@@ -31,5 +31,5 @@ "minimist": ">=0.2.0" | ||
"scripts": { | ||
"test": "bash test/run_all.sh", | ||
"test": "node test/run_tests.js", | ||
"prepublish": "make js" | ||
} | ||
} |
@@ -79,3 +79,3 @@ /** | ||
if (esprima.hasOwnProperty("typeAnnotation") && | ||
typeof(esprima.typeAnnotation) == "undefined") { | ||
typeof esprima.typeAnnotation == "undefined") { | ||
esprima.typeAnnotation = null; | ||
@@ -160,2 +160,3 @@ } | ||
} | ||
esprima.decorators = []; | ||
break; | ||
@@ -342,3 +343,3 @@ case 'ClassExpression': | ||
function runTest(test, esprima_opts) { | ||
function runTest(test, esprima_options, test_options) { | ||
var env = new_env(); | ||
@@ -357,3 +358,3 @@ var comparing_errors = false; | ||
try { | ||
var flow_ast = flow.parse(test.content); | ||
var flow_ast = flow.parse(test.content, {}); | ||
} catch (e) { | ||
@@ -366,4 +367,4 @@ output("Flow exploded:", util.inspect(e, {depth: null})); | ||
var options = { loc: true, comment: true, range: true }; | ||
for (opt in esprima_opts) { | ||
options[opt] = esprima_opts[opt]; | ||
for (opt in esprima_options) { | ||
options[opt] = esprima_options[opt]; | ||
} | ||
@@ -373,3 +374,3 @@ var esprima_ast = esprima.parse(test.content, options); | ||
comparing_errors = true; | ||
if (test.dumpAst) { | ||
if (test_options.dumpAst) { | ||
console.log("Esprima AST: ", util.inspect(e, {depth: null, colors: true})); | ||
@@ -410,3 +411,3 @@ console.log("Flow AST: ", util.inspect(flow_ast, {depth: null, colors: true})); | ||
if (!comparing_errors) { | ||
if (test.dumpAst) { | ||
if (test_options.dumpAst) { | ||
console.log("Esprima AST: ", util.inspect(esprima_ast, {depth: null, colors: true})); | ||
@@ -451,3 +452,3 @@ console.log("Flow AST: ", util.inspect(flow_ast, {depth: null, colors: true})); | ||
if (test.showDifferences) { | ||
if (test_options.showDifferences) { | ||
test.expected_differences = {}; | ||
@@ -486,3 +487,3 @@ output(test.explanation || "No explanation provided"); | ||
if (test.jsonErrors) { | ||
if (test_options.jsonErrors) { | ||
diff_to_string = function (e) { return util.inspect(e, { depth: null }); }; | ||
@@ -489,0 +490,0 @@ } |
@@ -149,3 +149,3 @@ var flow = require("./../flow_parser.js"); | ||
function runTest(test) { | ||
function runTest(test, parse_options, test_options) { | ||
var result = { | ||
@@ -162,3 +162,3 @@ passed: true, | ||
try { | ||
var flow_ast = flow.parse(test.content); | ||
var flow_ast = flow.parse(test.content, parse_options); | ||
} catch (e) { | ||
@@ -169,3 +169,3 @@ output("Flow exploded:", util.inspect(e, {depth: null})); | ||
} | ||
if (test.dumpAst) { | ||
if (test_options.dumpAst) { | ||
console.log("AST: ", util.inspect(flow_ast, {depth: null, colors: true})); | ||
@@ -177,6 +177,6 @@ output("AST: ", util.inspect(flow_ast, {depth: null, colors: true})); | ||
check_ast(env, flow_ast); | ||
compare(env, flow_ast, test.spec); | ||
compare(env, flow_ast, test.expected_ast); | ||
var diffs = env.get_diffs(); | ||
if (test.jsonErrors) { | ||
if (test_options.jsonErrors) { | ||
diff_to_string = function (e) { return util.inspect(e, { depth: null }); }; | ||
@@ -204,3 +204,11 @@ } | ||
if (flow_errors.length !== 0 && !test.spec.hasOwnProperty('errors')) { | ||
var expected_to_error = test.expected_ast.hasOwnProperty('errors') && test.expected_ast.errors != []; | ||
for (var prop in test.expected_ast) { | ||
if (test.expected_ast.hasOwnProperty(prop) && prop.match(/^errors\./)) { | ||
expected_to_error = true; | ||
break; | ||
} | ||
} | ||
if (flow_errors.length !== 0 && !expected_to_error) { | ||
result.passed = false; | ||
@@ -207,0 +215,0 @@ output("****Unexpected Errors****"); |
@@ -5,3 +5,10 @@ #!/usr/bin/env node | ||
var fs = require("fs"); | ||
var argv = require("minimist")(process.argv.slice(2)); | ||
var argv = require("minimist")( | ||
process.argv.slice(2), | ||
{ | ||
boolean: [ | ||
"strip-comments" | ||
], | ||
} | ||
); | ||
@@ -21,3 +28,7 @@ var description = | ||
} | ||
console.log(JSON.stringify(flow.parse(content), null, 2)); | ||
var ast = flow.parse(content, {}); | ||
if (argv['strip-comments']) { | ||
delete ast.comments; | ||
} | ||
console.log(JSON.stringify(ast, null, 2)); | ||
} |
@@ -35,6 +35,5 @@ #!/usr/bin/env node | ||
var result; | ||
var ast = flow.parse(data); | ||
try { | ||
process.stdout.write(filename + " : ... "); | ||
var ast = flow.parse(data); | ||
var ast = flow.parse(data, {}); | ||
if (ast.errors.length > 0) { | ||
@@ -41,0 +40,0 @@ result = error("Parse errors!", ast.errors); |
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 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
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
602095
15603
17
+ Addedast-types@0.8.14(transitive)
- Removedast-types@0.8.4(transitive)
Updatedast-types@0.8.14