Debian Codegraph @

js/src/jit-test/tests/modules/shell-parse.js

raw
1 // Exercise shell parseModule function.
2
3 function testEvalError(source) {
4 // Test |source| throws when passed to eval.
5 var caught = false;
6 try {
7 eval(source);
8 } catch (e) {
9 caught = true;
10 }
11 assertEq(caught, true);
12 }
13
14 function testModuleSource(source) {
15 // Test |source| parses as a module, but throws when passed to eval.
16 testEvalError(source);
17 parseModule(source);
18 }
19
20 parseModule("");
21 parseModule("const foo = 1;");
22 parseModule("var foo = 1;");
23 parseModule("let foo = 1; var bar = 2; const baz = 3");
24
25 testModuleSource("import * as ns from 'bar';");
26 testModuleSource("export { a } from 'b';");
27 testModuleSource("export * from 'b';");
28 testModuleSource("export const foo = 1;");
29 testModuleSource("export default function() {};");
30 testModuleSource("export default 1;");