Skip to content

Commit

Permalink
Add tests from babel/babel#12933
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Mar 29, 2021
1 parent 84b9455 commit fc16db7
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/misc/errors/js/assignment/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snippet: #0 [babel] format 1`] = `
"Invalid parenthesized assignment pattern (1:1)
> 1 | ({}) = x;
| ^"
`;

exports[`snippet: #0 [babel-ts] format 1`] = `
"Invalid parenthesized assignment pattern (1:1)
> 1 | ({}) = x;
| ^"
`;

exports[`snippet: #0 [espree] format 1`] = `
"Parenthesized pattern (1:1)
> 1 | ({}) = x;
| ^"
`;

exports[`snippet: #0 [meriyah] format 1`] = `
"[1:6]: Invalid left-hand side in assignment (1:6)
> 1 | ({}) = x;
| ^"
`;
7 changes: 7 additions & 0 deletions tests/misc/errors/js/assignment/jsfmt.spec.js
@@ -0,0 +1,7 @@
run_spec(
{
dirname: __dirname,
snippets: ["({}) = x;"],
},
["babel", "babel-ts", "espree", "meriyah"]
);
24 changes: 24 additions & 0 deletions tests/typescript/assignment/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -179,3 +179,27 @@ const firestorePersonallyIdentifiablePaths: Array<Collections.Users.Entity> =
================================================================================
`;
exports[`parenthesized.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// https://github.com/babel/babel/pull/12933/files
(<number>x) = null;
(x!) = null;
(a as any) = null;
(a as number) = 42;
((a as any) as string) = null;
=====================================output=====================================
// https://github.com/babel/babel/pull/12933/files
(<number>x) = null;
x! = null;
(a as any) = null;
(a as number) = 42;
((a as any) as string) = null;
================================================================================
`;
6 changes: 6 additions & 0 deletions tests/typescript/assignment/parenthesized.ts
@@ -0,0 +1,6 @@
// https://github.com/babel/babel/pull/12933/files
(<number>x) = null;
(x!) = null;
(a as any) = null;
(a as number) = 42;
((a as any) as string) = null;

0 comments on commit fc16db7

Please sign in to comment.