diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-08-23 01:43:12 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-08-23 01:43:12 +0200 |
commit | dd33cb382321351aa3b960a6824cb9ec43bba05b (patch) | |
tree | 729b4065b2a1c849d1fb6ad28b7e0c510f1a6a67 /js/src/jit-test/tests/modules/function-redeclaration.js | |
parent | 6a6e4bd25d61ecf21a28ea47f2a74927553fe959 (diff) | |
parent | ab6242a93b849b0a3c7525b16bc01dd3172fc167 (diff) | |
download | UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar.gz UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar.lz UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar.xz UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.zip |
Merge branch 'master' into Pale_Moon-release
Diffstat (limited to 'js/src/jit-test/tests/modules/function-redeclaration.js')
-rw-r--r-- | js/src/jit-test/tests/modules/function-redeclaration.js | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/modules/function-redeclaration.js b/js/src/jit-test/tests/modules/function-redeclaration.js new file mode 100644 index 000000000..b84704641 --- /dev/null +++ b/js/src/jit-test/tests/modules/function-redeclaration.js @@ -0,0 +1,94 @@ +load(libdir + "asserts.js"); + +var functionDeclarations = [ + "function f(){}", + "function* f(){}", + "async function f(){}", +]; + +var varDeclarations = [ + "var f", + "{ var f; }", + "for (var f in null);", + "for (var f of null);", + "for (var f; ;);", +]; + +var lexicalDeclarations = [ + "let f;", + "const f = 0;", + "class f {};", +]; + +var imports = [ + "import f from '';", + "import f, {} from '';", + "import d, {f} from '';", + "import d, {f as f} from '';", + "import d, {foo as f} from '';", + "import f, * as d from '';", + "import d, * as f from '';", + "import {f} from '';", + "import {f as f} from '';", + "import {foo as f} from '';", + "import* as f from '';", +]; + +var exports = [ + "export var f;", + ...functionDeclarations.map(fn => `export ${fn};`), + ...lexicalDeclarations.map(ld => `export ${ld};`), + ...functionDeclarations.map(fn => `export default ${fn};`), + "export default class f {};", +]; + +var redeclarations = [ + ...functionDeclarations, + ...varDeclarations, + ...lexicalDeclarations, + ...imports, + ...exports, +]; + +var noredeclarations = [ + ...functionDeclarations.map(fn => `{ ${fn} }`), + ...lexicalDeclarations.map(ld => `{ ${ld} }`), + ...["let", "const"].map(ld => `for (${ld} f in null);`), + ...["let", "const"].map(ld => `for (${ld} f of null);`), + ...["let", "const"].map(ld => `for (${ld} f = 0; ;);`), + "export {f};", + "export {f as f};", + "export {foo as f}; var foo;", + "export {f} from '';", + "export {f as f} from '';", + "export {foo as f} from '';", +]; + +for (var decl of functionDeclarations) { + for (var redecl of redeclarations) { + assertThrowsInstanceOf(() => { + parseModule(` + ${decl} + ${redecl} + `); + }, SyntaxError); + + assertThrowsInstanceOf(() => { + parseModule(` + ${redecl} + ${decl} + `); + }, SyntaxError); + } + + for (var redecl of noredeclarations) { + parseModule(` + ${decl} + ${redecl} + `); + parseModule(` + ${redecl} + ${decl} + `); + } +} |