Add test for invalid initializer in for..in (#19888)
This commit is contained in:
1 parent
5d2f938850
commit
91ee328608
2 files changed
+194
No files matched your search
+169
@@ -0,0 +1,169 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`snippet: #0 format[acorn] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^
|
||||
Cause: for-in loop variable declaration may not have an initializer (1:5)"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[espree] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^
|
||||
Cause: for-in loop variable declaration may not have an initializer"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[flow] 1`] = `
|
||||
"Invalid left-hand side in for-in (1:6)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^
|
||||
Cause: Invalid left-hand side in for-in (1:5)"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[hermes] 1`] = `
|
||||
"for-in/for-of variable declaration may not be initialized (1:14)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^
|
||||
Cause: for-in/for-of variable declaration may not be initialized (1:13)
|
||||
for (let a = 1 in b);
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[meriyah] 1`] = `
|
||||
"'for-in' loop head declarations can not have an initializer (1:10)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^^^^^^^^
|
||||
Cause: [1:9-1:17]: 'for-in' loop head declarations can not have an initializer"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[oxc] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^^^^^^^^^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[oxc-ts] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^^^^^^^^^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[typescript] 1`] = `
|
||||
"The variable declaration of a 'for...in' statement cannot have an initializer. (1:10)
|
||||
> 1 | for (let a = 1 in b);
|
||||
| ^^^^^
|
||||
Cause: The variable declaration of a 'for...in' statement cannot have an initializer."
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[acorn] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^
|
||||
Cause: for-in loop variable declaration may not have an initializer (1:5)"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[espree] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^
|
||||
Cause: for-in loop variable declaration may not have an initializer"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[flow] 1`] = `
|
||||
"Invalid left-hand side in for-in (1:6)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^
|
||||
Cause: Invalid left-hand side in for-in (1:5)"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[hermes] 1`] = `
|
||||
"for-in/for-of variable declaration may not be initialized (1:16)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^
|
||||
Cause: for-in/for-of variable declaration may not be initialized (1:15)
|
||||
for (const a = 1 in b);
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[meriyah] 1`] = `
|
||||
"'for-in' loop head declarations can not have an initializer (1:12)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^^^^^^^^
|
||||
Cause: [1:11-1:19]: 'for-in' loop head declarations can not have an initializer"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[oxc] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^^^^^^^^^^^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[oxc-ts] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:6)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^^^^^^^^^^^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[typescript] 1`] = `
|
||||
"The variable declaration of a 'for...in' statement cannot have an initializer. (1:12)
|
||||
> 1 | for (const a = 1 in b);
|
||||
| ^^^^^
|
||||
Cause: The variable declaration of a 'for...in' statement cannot have an initializer."
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[acorn] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:7)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^
|
||||
Cause: for-in loop variable declaration may not have an initializer (1:6)"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[espree] 1`] = `
|
||||
"for-in loop variable declaration may not have an initializer (1:7)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^
|
||||
Cause: for-in loop variable declaration may not have an initializer"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[flow] 1`] = `
|
||||
"Unexpected identifier, expected the token \`;\` (1:13)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^
|
||||
Cause: Unexpected identifier, expected the token \`;\` (1:12)"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[hermes] 1`] = `
|
||||
"';' or 'in' expected inside 'for' (1:15)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^
|
||||
Cause: ';' or 'in' expected inside 'for' (1:14)
|
||||
{for (using a = 1 in b);}
|
||||
~~~~~~~~~~~~~^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[meriyah] 1`] = `
|
||||
"'for-in' loop head declarations can not have an initializer (1:13)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^^^^^^^^
|
||||
Cause: [1:12-1:20]: 'for-in' loop head declarations can not have an initializer"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[oxc] 1`] = `
|
||||
"Expected \`;\` but found \`)\` (1:23)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[oxc-ts] 1`] = `
|
||||
"Expected \`;\` but found \`)\` (1:23)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #2 format[typescript] 1`] = `
|
||||
"The variable declaration of a 'for...in' statement cannot have an initializer. (1:13)
|
||||
> 1 | {for (using a = 1 in b);}
|
||||
| ^^^^^
|
||||
Cause: The variable declaration of a 'for...in' statement cannot have an initializer."
|
||||
`;
|
||||
@@ -0,0 +1,25 @@
|
||||
runFormatTest(
|
||||
{
|
||||
importMeta: import.meta,
|
||||
snippets: [
|
||||
"for (let a = 1 in b);",
|
||||
"for (const a = 1 in b);",
|
||||
"{for (using a = 1 in b);}",
|
||||
],
|
||||
},
|
||||
[
|
||||
// "babel",
|
||||
"acorn",
|
||||
"espree",
|
||||
"meriyah",
|
||||
"typescript",
|
||||
// "babel-ts",
|
||||
"oxc",
|
||||
"oxc-ts",
|
||||
// "yuku",
|
||||
// "yuku-ts",
|
||||
"flow",
|
||||
"hermes",
|
||||
// "__babel_estree",
|
||||
],
|
||||
);
|
||||
Reference in new issue
Block a user