summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Expressions/shell.js
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_6/Expressions/shell.js
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_6/Expressions/shell.js')
-rw-r--r--js/src/tests/ecma_6/Expressions/shell.js186
1 files changed, 186 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Expressions/shell.js b/js/src/tests/ecma_6/Expressions/shell.js
new file mode 100644
index 000000000..0a0a24656
--- /dev/null
+++ b/js/src/tests/ecma_6/Expressions/shell.js
@@ -0,0 +1,186 @@
+(function(global) {
+ function func() {
+ }
+ class C {
+ foo() {
+ }
+ static foo() {
+ }
+ }
+
+ function test_one(pattern, val, opt) {
+ var stmts = [];
+ var i = 0;
+ var c;
+
+ stmts.push(`var ${pattern} = ${val};`);
+ if (!opt.no_comp) {
+ stmts.push(`[for (x of [1]) ${pattern} = ${val}];`);
+ stmts.push(`[...(for (x of [1]) ${pattern} = ${val})];`);
+ }
+
+ for (var stmt of stmts) {
+ if (!opt.no_plain) {
+ eval(`
+${stmt}
+`);
+ }
+
+ if (!opt.no_func) {
+ eval(`
+function f${i}() {
+ ${stmt}
+}
+f${i}();
+`);
+ i++;
+
+ eval(`
+var f${i} = function foo() {
+ ${stmt}
+};
+f${i}();
+`);
+ i++;
+
+ eval(`
+var f${i} = () => {
+ ${stmt}
+};
+f${i}();
+`);
+ i++;
+ }
+
+ if (!opt.no_gen) {
+ eval(`
+function* g${i}() {
+ ${stmt}
+}
+[...g${i}()];
+`);
+ i++;
+
+ eval(`
+var g${i} = function* foo() {
+ ${stmt}
+};
+[...g${i}()];
+`);
+ i++;
+ }
+
+ if (!opt.no_ctor) {
+ eval(`
+class D${i} {
+ constructor() {
+ ${stmt}
+ }
+}
+new D${i}();
+`);
+ i++;
+ }
+
+ if (!opt.no_derived_ctor) {
+ if (opt.no_pre_super) {
+ eval(`
+class D${i} extends C {
+ constructor() {
+ ${stmt}
+ try { super(); } catch (e) {}
+ }
+}
+new D${i}();
+`);
+ i++;
+ } else {
+ eval(`
+class D${i} extends C {
+ constructor() {
+ super();
+ ${stmt}
+ }
+}
+new D${i}();
+`);
+ i++;
+ }
+ }
+
+ if (!opt.no_method) {
+ eval(`
+class D${i} extends C {
+ method() {
+ ${stmt}
+ }
+ static staticMethod() {
+ ${stmt}
+ }
+}
+new D${i}().method();
+D${i}.staticMethod();
+`);
+ i++;
+ }
+ }
+
+ if (!opt.no_func_arg) {
+ eval(`
+function f${i}(${pattern}) {}
+f${i}(${val});
+`);
+ i++;
+
+ eval(`
+var f${i} = function foo(${pattern}) {};
+f${i}(${val});
+`);
+ i++;
+
+ eval(`
+var f${i} = (${pattern}) => {};
+f${i}(${val});
+`);
+ i++;
+ }
+
+ if (!opt.no_gen_arg) {
+ eval(`
+function* g${i}(${pattern}) {}
+[...g${i}(${val})];
+`);
+ i++;
+
+ eval(`
+var g${i} = function* foo(${pattern}) {};
+[...g${i}(${val})];
+`);
+ i++;
+ }
+ }
+
+ function test(expr, opt={}) {
+ var pattern = `[a=${expr}, ...c]`;
+ test_one(pattern, "[]", opt);
+ test_one(pattern, "[1]", opt);
+
+ pattern = `[,a=${expr}]`;
+ test_one(pattern, "[]", opt);
+ test_one(pattern, "[1]", opt);
+ test_one(pattern, "[1, 2]", opt);
+
+ pattern = `[{x: [a=${expr}]}]`;
+ test_one(pattern, "[{x: [1]}]", opt);
+
+ pattern = `[x=[a=${expr}]=[]]`;
+ test_one(pattern, "[]", opt);
+ test_one(pattern, "[1]", opt);
+
+ pattern = `[x=[a=${expr}]=[1]]`;
+ test_one(pattern, "[]", opt);
+ test_one(pattern, "[1]", opt);
+ }
+
+ global.testDestructuringArrayDefault = test;
+})(this);