improve babylon test coverage and remove dead code
This commit is contained in:
1
test/fixtures/flow/declare-statements/invalid/actual.js
vendored
Normal file
1
test/fixtures/flow/declare-statements/invalid/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare foobar
|
||||
3
test/fixtures/flow/declare-statements/invalid/options.json
vendored
Normal file
3
test/fixtures/flow/declare-statements/invalid/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:8)"
|
||||
}
|
||||
3
test/fixtures/harmony/computed-properties/call-expression/actual.js
vendored
Normal file
3
test/fixtures/harmony/computed-properties/call-expression/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var foo = {
|
||||
[bar()]: ""
|
||||
};
|
||||
169
test/fixtures/harmony/computed-properties/call-expression/expected.json
vendored
Normal file
169
test/fixtures/harmony/computed-properties/call-expression/expected.json
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 4,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 4,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"init": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 10,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "Property",
|
||||
"start": 14,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"shorthand": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "CallExpression",
|
||||
"start": 15,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"name": "bar"
|
||||
},
|
||||
"arguments": []
|
||||
},
|
||||
"value": {
|
||||
"type": "Literal",
|
||||
"start": 23,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"value": "",
|
||||
"rawValue": "",
|
||||
"raw": "\"\""
|
||||
},
|
||||
"kind": "init"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
}
|
||||
]
|
||||
},
|
||||
"comments": []
|
||||
}
|
||||
1
test/fixtures/jsx/errors/attribute-arbitrary-expression/actual.js
vendored
Normal file
1
test/fixtures/jsx/errors/attribute-arbitrary-expression/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<Foo bar=bar() />
|
||||
3
test/fixtures/jsx/errors/attribute-arbitrary-expression/options.json
vendored
Normal file
3
test/fixtures/jsx/errors/attribute-arbitrary-expression/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "JSX value should be either an expression or a quoted JSX text (1:9)"
|
||||
}
|
||||
1
test/fixtures/jsx/errors/attribute-empty-expression/actual.js
vendored
Normal file
1
test/fixtures/jsx/errors/attribute-empty-expression/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<foo bar={} />
|
||||
3
test/fixtures/jsx/errors/attribute-empty-expression/options.json
vendored
Normal file
3
test/fixtures/jsx/errors/attribute-empty-expression/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "JSX attributes must only be assigned a non-empty expression (1:9)"
|
||||
}
|
||||
1
test/fixtures/jsx/errors/unclosed-tag/actual.js
vendored
Normal file
1
test/fixtures/jsx/errors/unclosed-tag/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<foo>yes
|
||||
3
test/fixtures/jsx/errors/unclosed-tag/options.json
vendored
Normal file
3
test/fixtures/jsx/errors/unclosed-tag/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unterminated JSX contents (1:5)"
|
||||
}
|
||||
1
test/fixtures/jsx/errors/unterminated-string/actual.js
vendored
Normal file
1
test/fixtures/jsx/errors/unterminated-string/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<foo bar="
|
||||
3
test/fixtures/jsx/errors/unterminated-string/options.json
vendored
Normal file
3
test/fixtures/jsx/errors/unterminated-string/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unterminated string constant (1:9)"
|
||||
}
|
||||
@@ -18,6 +18,12 @@ _.each(fixtures, function (suites, name) {
|
||||
});
|
||||
});
|
||||
|
||||
function save(test, ast) {
|
||||
delete ast.tokens;
|
||||
if (!ast.comments.length) delete ast.comments;
|
||||
require("fs").writeFileSync(test.expect.loc, JSON.stringify(ast, null, " "));
|
||||
}
|
||||
|
||||
function runTest(test) {
|
||||
var opts = test.options;
|
||||
opts.locations = true;
|
||||
@@ -38,18 +44,21 @@ function runTest(test) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!test.expect.code) {
|
||||
test.expect.loc += "on";
|
||||
return save(test, ast);
|
||||
}
|
||||
|
||||
if (opts.throws) {
|
||||
throw new Error("Expected error message: " + opts.throws + ". But parsing succeeded.");
|
||||
} else {
|
||||
try {
|
||||
var mis = misMatch(JSON.parse(test.expect.code), ast);
|
||||
} catch (err) {
|
||||
console.log(test.expect.code);
|
||||
// save(test, ast);
|
||||
throw err;
|
||||
}
|
||||
if (mis) {
|
||||
//delete ast.tokens;
|
||||
//require("fs").writeFileSync(test.expect.loc, JSON.stringify(ast, null, " "));
|
||||
throw new Error(mis);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user