Rewrite tests for importing JSON (#16517)
This commit is contained in:
1 parent
69f419213e
commit
0f9a1aefee
5 files changed
+78
-27
No files matched your search
@@ -88,6 +88,60 @@ import * as baz from "baz.json" /* comment */ assert {};
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`keyword-detect.js [acorn] format 1`] = `
|
||||
"Unexpected token (1:33)
|
||||
> 1 | import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
| ^
|
||||
2 | import {default as b} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
3 |
|
||||
4 | export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
Cause: Unexpected token (1:32)"
|
||||
`;
|
||||
|
||||
exports[`keyword-detect.js [espree] format 1`] = `
|
||||
"Unexpected token assert (1:33)
|
||||
> 1 | import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
| ^
|
||||
2 | import {default as b} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
3 |
|
||||
4 | export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
Cause: Unexpected token assert"
|
||||
`;
|
||||
|
||||
exports[`keyword-detect.js [meriyah] format 1`] = `
|
||||
"Unexpected token: 'identifier' (1:33)
|
||||
> 1 | import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
| ^^^^^^
|
||||
2 | import {default as b} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
3 |
|
||||
4 | export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
Cause: [1:32-1:38]: Unexpected token: 'identifier'"
|
||||
`;
|
||||
|
||||
exports[`keyword-detect.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
import {default as b} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
|
||||
export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
|
||||
export * from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
|
||||
=====================================output=====================================
|
||||
import "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
import { default as b } from "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
|
||||
export { default as e } from "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
|
||||
export * from "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`multi-types.js [acorn] format 1`] = `
|
||||
"Unexpected token (1:31)
|
||||
> 1 | import json from "./foo.json" assert { type: "json", type: "bar" };
|
||||
|
||||
@@ -8,6 +8,7 @@ runFormatTest(import.meta, ["babel", "typescript"], {
|
||||
"re-export.js",
|
||||
"without-from.js",
|
||||
"non-type.js",
|
||||
"keyword-detect.js",
|
||||
],
|
||||
espree: [
|
||||
"dynamic-import.js",
|
||||
@@ -17,6 +18,7 @@ runFormatTest(import.meta, ["babel", "typescript"], {
|
||||
"re-export.js",
|
||||
"without-from.js",
|
||||
"non-type.js",
|
||||
"keyword-detect.js",
|
||||
],
|
||||
meriyah: [
|
||||
"empty.js",
|
||||
@@ -25,6 +27,7 @@ runFormatTest(import.meta, ["babel", "typescript"], {
|
||||
"re-export.js",
|
||||
"without-from.js",
|
||||
"non-type.js",
|
||||
"keyword-detect.js",
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
import {default as b} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
|
||||
export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
|
||||
export * from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
@@ -82,9 +82,9 @@ exports[`keyword-detect.js [acorn] format 1`] = `
|
||||
"Unexpected token (1:35)
|
||||
> 1 | import "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
| ^
|
||||
2 | import {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
3 | import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
4 | import {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
2 | import a from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
3 |
|
||||
4 | export {default as c} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
Cause: Unexpected token (1:34)"
|
||||
`;
|
||||
|
||||
@@ -92,9 +92,9 @@ exports[`keyword-detect.js [espree] format 1`] = `
|
||||
"Unexpected token with (1:35)
|
||||
> 1 | import "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
| ^
|
||||
2 | import {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
3 | import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
4 | import {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
2 | import a from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
3 |
|
||||
4 | export {default as c} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
Cause: Unexpected token with"
|
||||
`;
|
||||
|
||||
@@ -102,9 +102,9 @@ exports[`keyword-detect.js [meriyah] format 1`] = `
|
||||
"Invalid binding in JSON import (1:69)
|
||||
> 1 | import "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
| ^
|
||||
2 | import {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
3 | import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
4 | import {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
2 | import a from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
3 |
|
||||
4 | export {default as c} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
Cause: [1:68-1:69]: Invalid binding in JSON import"
|
||||
`;
|
||||
|
||||
@@ -115,27 +115,19 @@ printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
import "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
import {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
import {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
import a from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
|
||||
export {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
export {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
export {default as c} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
|
||||
export * from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
export * from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
|
||||
=====================================output=====================================
|
||||
import "./test.json" /* assert */ /* assert */ with { type: "json" };
|
||||
import {} from "./test.json" /* assert */ /* assert */ with { type: "json" };
|
||||
import "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
import {} from "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
import a from "./test.json" /* assert */ /* assert */ with { type: "json" };
|
||||
|
||||
export {} from "./test.json" /* assert */ /* assert */ with { type: "json" };
|
||||
export {} from "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
export { default as c } from "./test.json" /* assert */ /* assert */ with { type: "json" };
|
||||
|
||||
export * from "./test.json" /* assert */ /* assert */ with { type: "json" };
|
||||
export * from "./test.json" /* with */ /* with */ assert { type: "json" };
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
import {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
import "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
import {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
import a from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
|
||||
export {} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
export {} from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
export {default as c} from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
|
||||
export * from "./test.json" /* assert */ with /* assert */ { type: "json" }
|
||||
export * from "./test.json" /* with */ assert /* with */ { type: "json" }
|
||||
Reference in new issue
Block a user