summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/Syntax
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_7/Syntax
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_7/Syntax')
-rw-r--r--js/src/tests/ecma_7/Syntax/browser.js0
-rw-r--r--js/src/tests/ecma_7/Syntax/non-simple-with-strict-directive.js140
-rw-r--r--js/src/tests/ecma_7/Syntax/shell.js0
3 files changed, 140 insertions, 0 deletions
diff --git a/js/src/tests/ecma_7/Syntax/browser.js b/js/src/tests/ecma_7/Syntax/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_7/Syntax/browser.js
diff --git a/js/src/tests/ecma_7/Syntax/non-simple-with-strict-directive.js b/js/src/tests/ecma_7/Syntax/non-simple-with-strict-directive.js
new file mode 100644
index 000000000..a0e536687
--- /dev/null
+++ b/js/src/tests/ecma_7/Syntax/non-simple-with-strict-directive.js
@@ -0,0 +1,140 @@
+/* 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/. */
+
+const testCases = [
+ // Array destructuring.
+ "[]",
+ "[a]",
+ "x, [a]",
+ "[a], x",
+
+ // Array destructuring with defaults.
+ "[a = 0]",
+ "x, [a = 0]",
+ "[a = 0], x",
+
+ // Array destructuring with rest binding identifier.
+ "[...a]",
+ "x, [...a]",
+ "[...a], x",
+
+ // Array destructuring with rest binding pattern.
+ "[...[a]]",
+ "x, [...[a]]",
+ "[...[a]], x",
+
+ // Object destructuring.
+ "{}",
+ "{p: o}",
+ "x, {p: o}",
+ "{p: o}, x",
+
+ // Object destructuring with defaults.
+ "{p: o = 0}",
+ "x, {p: o = 0}",
+ "{p: o = 0}, x",
+
+ // Object destructuring with shorthand identifier form.
+ "{o}",
+ "x, {o}",
+ "{o}, x",
+
+ // Object destructuring with CoverInitName.
+ "{o = 0}",
+ "x, {o = 0}",
+ "{o = 0}, x",
+
+ // Default parameter.
+ "d = 0",
+ "x, d = 0",
+ "d = 0, x",
+
+ // Rest parameter.
+ "...rest",
+ "x, ...rest",
+
+ // Rest parameter with array destructuring.
+ "...[]",
+ "...[a]",
+ "x, ...[]",
+ "x, ...[a]",
+
+ // Rest parameter with object destructuring.
+ "...{}",
+ "...{p: o}",
+ "x, ...{}",
+ "x, ...{p: o}",
+
+ // All non-simple cases combined.
+ "x, d = 123, [a], {p: 0}, ...rest",
+];
+
+const GeneratorFunction = function*(){}.constructor;
+
+const functionDefinitions = [
+ // FunctionDeclaration
+ parameters => `function f(${parameters}) { "use strict"; }`,
+
+ // FunctionExpression
+ parameters => `void function(${parameters}) { "use strict"; };`,
+ parameters => `void function f(${parameters}) { "use strict"; };`,
+
+ // Function constructor
+ parameters => `Function('${parameters}', '"use strict";')`,
+
+ // GeneratorDeclaration
+ parameters => `function* g(${parameters}) { "use strict"; }`,
+
+ // GeneratorExpression
+ parameters => `void function*(${parameters}) { "use strict"; };`,
+ parameters => `void function* g(${parameters}) { "use strict"; };`,
+
+ // GeneratorFunction constructor
+ parameters => `GeneratorFunction('${parameters}', '"use strict";')`,
+
+ // MethodDefinition
+ parameters => `({ m(${parameters}) { "use strict"; } });`,
+ parameters => `(class { m(${parameters}) { "use strict"; } });`,
+ parameters => `class C { m(${parameters}) { "use strict"; } }`,
+
+ // MethodDefinition (constructors)
+ parameters => `(class { constructor(${parameters}) { "use strict"; } });`,
+ parameters => `class C { constructor(${parameters}) { "use strict"; } }`,
+
+ // MethodDefinition (getter)
+ parameters => `({ get m(${parameters}) { "use strict"; } });`,
+ parameters => `(class { get m(${parameters}) { "use strict"; } });`,
+ parameters => `class C { get m(${parameters}) { "use strict"; } }`,
+
+ // MethodDefinition (setter)
+ parameters => `({ set m(${parameters}) { "use strict"; } });`,
+ parameters => `(class { set m(${parameters}) { "use strict"; } });`,
+ parameters => `class C { set m(${parameters}) { "use strict"; } }`,
+
+ // GeneratorMethod
+ parameters => `({ *m(${parameters}) { "use strict"; } });`,
+ parameters => `(class { *m(${parameters}) { "use strict"; } });`,
+ parameters => `class C { *m(${parameters}) { "use strict"; } }`,
+
+ // ArrowFunction
+ parameters => `(${parameters}) => { "use strict"; };`,
+];
+
+for (let nonSimpleParameters of testCases) {
+ for (let def of functionDefinitions) {
+ // Non-strict script code.
+ assertThrowsInstanceOf(() => eval(`
+ ${def(nonSimpleParameters)}
+ `), SyntaxError, def(nonSimpleParameters));
+
+ // Strict script code.
+ assertThrowsInstanceOf(() => eval(`
+ "use strict";
+ ${def(nonSimpleParameters)}
+ `), SyntaxError, `"use strict"; ${def(nonSimpleParameters)}`);
+ }
+}
+
+if (typeof reportCompare === 'function')
+ reportCompare(0, 0);
diff --git a/js/src/tests/ecma_7/Syntax/shell.js b/js/src/tests/ecma_7/Syntax/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_7/Syntax/shell.js