Skip to content

Commit

Permalink
Test: Allow multiple parsers in error test (#9648)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Nov 16, 2020
1 parent 76c6d97 commit 386759c
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 116 deletions.
4 changes: 2 additions & 2 deletions tests/misc/errors/babel-flow/__snapshots__/jsfmt.spec.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`async-arrow-invalid.js error test 1`] = `
exports[`async-arrow-invalid.js [babel] format 1`] = `
"Type parameters must come after the async keyword, e.g. instead of \`<T> async (3:1)
1 | // https://github.com/babel/babel/pull/11979
2 |
Expand All @@ -9,7 +9,7 @@ exports[`async-arrow-invalid.js error test 1`] = `
4 | "
`;
exports[`async-arrow-invalid.js error test 2`] = `
exports[`async-arrow-invalid.js [babel-flow] format 1`] = `
"Type parameters must come after the async keyword, e.g. instead of \`<T> async (3:1)
1 | // https://github.com/babel/babel/pull/11979
2 |
Expand Down
3 changes: 1 addition & 2 deletions tests/misc/errors/babel-flow/jsfmt.spec.js
@@ -1,2 +1 @@
run_spec(__dirname, ["babel-flow"]);
run_spec(__dirname, ["babel"]);
run_spec(__dirname, ["babel-flow", "babel"]);
6 changes: 3 additions & 3 deletions tests/misc/errors/babel-ts/__snapshots__/jsfmt.spec.js.snap
@@ -1,20 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`type-annotation-expr-statement.ts error test 1`] = `
exports[`type-annotation-expr-statement.ts [babel-ts] format 1`] = `
"Did not expect a type annotation here. (1:3)
> 1 | (a: T);
| ^
2 | "
`;

exports[`type-annotation-func.ts error test 1`] = `
exports[`type-annotation-func.ts [babel-ts] format 1`] = `
"Did not expect a type annotation here. (1:10)
> 1 | func<T>(a: T);
| ^
2 | "
`;
exports[`type-annotation-in-jsx.tsx error test 1`] = `
exports[`type-annotation-in-jsx.tsx [babel-ts] format 1`] = `
"Did not expect a type annotation here. (3:22)
1 | function Foo() {
2 | return (
Expand Down
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snippet: #0 error test 1`] = `"Comment \\"comment\\" was not printed. Please report this error!"`;
exports[`snippet: #0 [missing-comments] format 1`] = `"Comment \\"comment\\" was not printed. Please report this error!"`;
16 changes: 8 additions & 8 deletions tests/misc/errors/flow/__snapshots__/jsfmt.spec.js.snap
@@ -1,57 +1,57 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`async-arrow-invalid.js error test 1`] = `
exports[`async-arrow-invalid.js [flow] format 1`] = `
"Unexpected token ILLEGAL (4:1)
2 |
3 | <T> async () => {}
> 4 |
| ^"
`;

exports[`default-escaped.js error test 1`] = `
exports[`default-escaped.js [flow] format 1`] = `
"Unexpected identifier, expected the token \`{\` (1:8)
> 1 | export asyn\\\\u{63} from \\"async\\";
| ^^^^^^^^^^
2 | "
`;

exports[`dynamic-import.js error test 1`] = `
exports[`dynamic-import.js [flow] format 1`] = `
"Unexpected token \`,\`, expected the token \`)\` (1:24)
> 1 | import('./prettier.mjs', {})
| ^
2 | "
`;

exports[`function-async.js error test 1`] = `
exports[`function-async.js [flow] format 1`] = `
"Unexpected token \`;\`, expected the token \`=>\` (2:11)
1 | // Flow can't parse this since \`v0.128.0\`, #8661
> 2 | async<T>();
| ^"
`;

exports[`module-attributes-dynamic.js error test 1`] = `
exports[`module-attributes-dynamic.js [flow] format 1`] = `
"Unexpected token \`,\`, expected the token \`)\` (1:18)
> 1 | import(\\"foo.json\\", { with: { type: \\"json\\" } })
| ^
2 | "
`;

exports[`module-attributes-static.js error test 1`] = `
exports[`module-attributes-static.js [flow] format 1`] = `
"Unexpected token \`with\`, expected the token \`;\` (1:28)
> 1 | import foo from \\"foo.json\\" with type: \\"json\\";
| ^^^^
2 | "
`;

exports[`newline-before-arrow.js error test 1`] = `
exports[`newline-before-arrow.js [flow] format 1`] = `
"Illegal newline before arrow (2:1)
1 | async x
> 2 | => x
| ^^
3 | "
`;

exports[`number.js error test 1`] = `
exports[`number.js [flow] format 1`] = `
"Unexpected token ILLEGAL (3:5)
1 | // https://github.com/babel/babel/pull/11854
2 |
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/errors/graphql/__snapshots__/jsfmt.spec.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`type-interfaces.graphql error test 1`] = `
exports[`type-interfaces.graphql [graphql] format 1`] = `
"Syntax Error: Unexpected \\"|\\". (5:21)
3 | # which will break seperator detection added in #7305
4 |
Expand Down
6 changes: 3 additions & 3 deletions tests/misc/errors/handlebars/__snapshots__/jsfmt.spec.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`invalid.hbs error test 1`] = `
exports[`invalid.hbs [glimmer] format 1`] = `
"Parse error on line 2:
<A >x, {{@name}
--------------^
Expand All @@ -11,15 +11,15 @@ Expecting 'CLOSE_RAW_BLOCK', 'CLOSE', 'CLOSE_UNESCAPED', 'OPEN_SEXPR', 'CLOSE_SE
3 | "
`;

exports[`invalid-2.hbs error test 1`] = `
exports[`invalid-2.hbs [glimmer] format 1`] = `
"Unclosed element \`@name\` (on line 3). (3:0)
1 | <a>
2 |
> 3 | <{@name>
4 | "
`;

exports[`invalid-3.hbs error test 1`] = `
exports[`invalid-3.hbs [glimmer] format 1`] = `
"Parse error on line 3:
<a>{{}}
-----^
Expand Down
26 changes: 13 additions & 13 deletions tests/misc/errors/invalid/__snapshots__/jsfmt.spec.js.snap
@@ -1,37 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snippet: #0 error test 1`] = `
exports[`snippet: #0 [babel] format 1`] = `
"Unexpected token, expected \\"(\\" (1:5)
> 1 | for each (a in b) {}
| ^"
`;

exports[`snippet: #0 error test 2`] = `
"Unexpected identifier, expected the token \`(\` (1:5)
exports[`snippet: #0 [babel-flow] format 1`] = `
"Unexpected token, expected \\"(\\" (1:5)
> 1 | for each (a in b) {}
| ^^^^"
| ^"
`;

exports[`snippet: #0 error test 3`] = `
"'(' expected. (1:5)
exports[`snippet: #0 [babel-ts] format 1`] = `
"Unexpected token, expected \\"(\\" (1:5)
> 1 | for each (a in b) {}
| ^"
`;

exports[`snippet: #0 error test 4`] = `
"Unexpected token, expected \\"(\\" (1:5)
exports[`snippet: #0 [espree] format 1`] = `
"Unexpected token each (1:5)
> 1 | for each (a in b) {}
| ^"
`;

exports[`snippet: #0 error test 5`] = `
"Unexpected token, expected \\"(\\" (1:5)
exports[`snippet: #0 [flow] format 1`] = `
"Unexpected identifier, expected the token \`(\` (1:5)
> 1 | for each (a in b) {}
| ^"
| ^^^^"
`;

exports[`snippet: #0 error test 6`] = `
"Unexpected token each (1:5)
exports[`snippet: #0 [typescript] format 1`] = `
"'(' expected. (1:5)
> 1 | for each (a in b) {}
| ^"
`;
23 changes: 7 additions & 16 deletions tests/misc/errors/invalid/jsfmt.spec.js
@@ -1,16 +1,7 @@
for (const parser of [
"babel",
"flow",
"typescript",
"babel-flow",
"babel-ts",
"espree",
]) {
run_spec(
{
dirname: __dirname,
snippets: ["for each (a in b) {}"],
},
[parser]
);
}
run_spec(
{
dirname: __dirname,
snippets: ["for each (a in b) {}"],
},
["babel", "flow", "typescript", "babel-flow", "babel-ts", "espree"]
);
40 changes: 20 additions & 20 deletions tests/misc/errors/js/__snapshots__/jsfmt.spec.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-like-comments.js error test 1`] = `
exports[`html-like-comments.js [babel] format 1`] = `
"Unexpected token (3:1)
1 | // Only support HTML-like comment in HTML
2 | alert(
Expand All @@ -11,28 +11,28 @@ exports[`html-like-comments.js error test 1`] = `
6 | "
`;

exports[`import-assertions-for-export-without-from.js error test 1`] = `
exports[`import-assertions-for-export-without-from.js [babel] format 1`] = `
"Unexpected token, expected \\";\\" (1:16)
> 1 | export { foo } assert { type: \\"json\\" };
| ^
2 | "
`;

exports[`import-assertions-with-parens.js error test 1`] = `
exports[`import-assertions-with-parens.js [babel] format 1`] = `
"Unexpected token (1:19)
> 1 | import \\"x\\" assert ({type: 'json'});
| ^
2 | "
`;

exports[`module-attributes.js error test 1`] = `
exports[`module-attributes.js [babel] format 1`] = `
"Unexpected token, expected \\";\\" (1:28)
> 1 | import foo from \\"foo.json\\" with type: \\"json\\";
| ^
2 | "
`;

exports[`no-for-in-init-concise-binary-in.js error test 1`] = `
exports[`no-for-in-init-concise-binary-in.js [babel] format 1`] = `
"Unexpected token, expected \\")\\" (3:18)
1 | // https://github.com/babel/babel/pull/11931
2 |
Expand All @@ -41,7 +41,7 @@ exports[`no-for-in-init-concise-binary-in.js error test 1`] = `
4 | "
`;

exports[`partial-template-strings.js error test 1`] = `
exports[`partial-template-strings.js [babel] format 1`] = `
"Unexpected token (6:42)
4 |
5 | const Diagnostics = {
Expand All @@ -52,43 +52,43 @@ exports[`partial-template-strings.js error test 1`] = `
9 | Diagnostics.name_not_found(\\"foo\\"); // \\"'foo' not found.\\""
`;

exports[`snippet: #0 error test 1`] = `
exports[`snippet: #0 [babel] format 1`] = `
"Binding should be performed on object property. (1:3)
> 1 | ::%DebugPrint(null)
| ^"
`;

exports[`snippet: #1 error test 1`] = `
exports[`snippet: #1 [babel] format 1`] = `
"Unexpected token (1:3)
> 1 | a.%DebugPrint();
| ^"
`;

exports[`snippet: #2 error test 1`] = `
exports[`snippet: #2 [babel] format 1`] = `
"Unexpected token (1:11)
> 1 | const i = %DebugPrint;
| ^"
`;

exports[`snippet: #3 error test 1`] = `
exports[`snippet: #3 [babel] format 1`] = `
"Unexpected token (1:7)
> 1 | f(x + ?)
| ^"
`;

exports[`snippet: #4 error test 1`] = `
exports[`snippet: #4 [babel] format 1`] = `
"Unexpected token (1:5)
> 1 | x + ?
| ^"
`;

exports[`snippet: #5 error test 1`] = `
exports[`snippet: #5 [babel] format 1`] = `
"Unexpected token (1:1)
> 1 | ?.f()
| ^"
`;

exports[`snippet: #6 error test 1`] = `
exports[`snippet: #6 [babel] format 1`] = `
"Unexpected token (5:12)
3 |
4 | static isC(obj) {
Expand All @@ -98,43 +98,43 @@ exports[`snippet: #6 error test 1`] = `
7 | }"
`;

exports[`snippet: #7 error test 1`] = `
exports[`snippet: #7 [babel] format 1`] = `
"Unexpected token (1:7)
> 1 | const #{ a, b } = #{ a: 1, b: 2 };
| ^"
`;

exports[`snippet: #8 error test 1`] = `
exports[`snippet: #8 [babel] format 1`] = `
"Unexpected token (1:7)
> 1 | const #[a, b] = #[1, 2];
| ^"
`;

exports[`snippet: #9 error test 1`] = `
exports[`snippet: #9 [babel] format 1`] = `
"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar' (1:1)
> 1 | [| 1 |]
| ^"
`;

exports[`snippet: #10 error test 1`] = `
exports[`snippet: #10 [babel] format 1`] = `
"Invalid decimal (1:1)
> 1 | 0b101011101m;
| ^"
`;

exports[`snippet: #11 error test 1`] = `
exports[`snippet: #11 [babel] format 1`] = `
"Invalid decimal (1:1)
> 1 | 0x16432m;
| ^"
`;

exports[`snippet: #12 error test 1`] = `
exports[`snippet: #12 [babel] format 1`] = `
"Invalid decimal (1:1)
> 1 | 0o16432m;
| ^"
`;

exports[`static-import-source-should-not-has-extra-token.js error test 1`] = `
exports[`static-import-source-should-not-has-extra-token.js [babel] format 1`] = `
"Unexpected token (4:16)
2 | // be parenthesized, that accidentally break #8016
3 |
Expand Down

0 comments on commit 386759c

Please sign in to comment.