diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-06-08 14:51:46 -0400 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-07-18 22:38:14 -0400 |
commit | d5833cd1bf99a3188d02fe4ef77a51aea528d91f (patch) | |
tree | 18e5e9248a8011e44de84cb8b73f77f9027d0dd6 /js/src/tests | |
parent | 00926004dd81af6f9ed5857ae1360696c3468335 (diff) | |
download | uxp-d5833cd1bf99a3188d02fe4ef77a51aea528d91f.tar.gz |
1317379 - Disallow generator functions and async functions as direct children of if/else.
Diffstat (limited to 'js/src/tests')
-rw-r--r-- | js/src/tests/ecma_2017/AsyncFunctions/forbidden-as-consequent.js | 14 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Generators/forbidden-as-consequent.js | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/js/src/tests/ecma_2017/AsyncFunctions/forbidden-as-consequent.js b/js/src/tests/ecma_2017/AsyncFunctions/forbidden-as-consequent.js new file mode 100644 index 0000000000..656ed46deb --- /dev/null +++ b/js/src/tests/ecma_2017/AsyncFunctions/forbidden-as-consequent.js @@ -0,0 +1,14 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +assertThrowsInstanceOf(() => eval("if (1) async function foo() {}"), + SyntaxError); +assertThrowsInstanceOf(() => eval("'use strict'; if (1) async function foo() {}"), + SyntaxError); + +var async = 42; +assertEq(eval("if (1) async \n function foo() {}"), 42); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/ecma_6/Generators/forbidden-as-consequent.js b/js/src/tests/ecma_6/Generators/forbidden-as-consequent.js new file mode 100644 index 0000000000..13647e154b --- /dev/null +++ b/js/src/tests/ecma_6/Generators/forbidden-as-consequent.js @@ -0,0 +1,11 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +assertThrowsInstanceOf(() => eval("if (1) function* foo() {}"), + SyntaxError); +assertThrowsInstanceOf(() => eval("'use strict'; if (1) function* foo() {}"), + SyntaxError); + +if (typeof reportCompare === "function") + reportCompare(true, true); |