diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/Destructuring | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | uxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/Destructuring')
11 files changed, 1163 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Destructuring/browser.js b/js/src/tests/ecma_6/Destructuring/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/browser.js diff --git a/js/src/tests/ecma_6/Destructuring/cover-init-name-syntax.js b/js/src/tests/ecma_6/Destructuring/cover-init-name-syntax.js new file mode 100644 index 0000000000..b37d8c2904 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/cover-init-name-syntax.js @@ -0,0 +1,72 @@ +/* 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/. */ + + +// CoverInitName in arrow parameters. +({a = 1}, {b = 2}, {c = 3}) => {}; +({a = 1} = {}, {b = 2}, {c = 3}) => {}; +({a = 1} = {}, {b = 2} = {}, {c = 3}) => {}; +({a = 1} = {}, {b = 2} = {}, {c = 3} = {}) => {}; + + +// CoverInitName in CoverParenthesizedExpressionAndArrowParameterList, +// but not ArrowParameters. +assertThrowsInstanceOf(() => eval(` + ({a = 1}, {b = 2}, {c = 3}); +`), SyntaxError); +assertThrowsInstanceOf(() => eval(` + ({a = 1}, {b = 2}, {c = 3} = {}); +`), SyntaxError); +assertThrowsInstanceOf(() => eval(` + ({a = 1}, {b = 2} = {}, {c = 3} = {}); +`), SyntaxError); + + +// CoverInitName nested in array destructuring. +[{a = 0}] = [{}]; +var [{a = 0}] = [{}]; +{ let [{a = 0}] = [{}]; } +{ const [{a = 0}] = [{}]; } + +for ([{a = 0}] of []); +for (var [{a = 0}] of []); +for (let [{a = 0}] of []); +for (const [{a = 0}] of []); + +function f([{a = 0}]) {} +var h = ([{a = 0}]) => {}; + + +// CoverInitName nested in rest pattern. +[...[{a = 0}]] = [{}]; +var [...[{a = 0}]] = [{}]; +{ let [...[{a = 0}]] = [{}]; } +{ const [...[{a = 0}]] = [{}]; } + +for ([...[{a = 0}]] of []); +for (var [...[{a = 0}]] of []); +for (let [...[{a = 0}]] of []); +for (const [...[{a = 0}]] of []); + +function f([...[{a = 0}]]) {} +var h = ([...[{a = 0}]]) => {}; + + +// CoverInitName nested in object destructuring. +({p: {a = 0}} = {p: {}}); +var {p: {a = 0}} = {p: {}}; +{ let {p: {a = 0}} = {p: {}}; } +{ const {p: {a = 0}} = {p: {}}; } + +for ({p: {a = 0}} of []); +for (var {p: {a = 0}} of []); +for (let {p: {a = 0}} of []); +for (const {p: {a = 0}} of []); + +function f({p: {a = 0}}) {} +var h = ({p: {a = 0}}) => {}; + + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/ecma_6/Destructuring/iterator-primitive.js b/js/src/tests/ecma_6/Destructuring/iterator-primitive.js new file mode 100644 index 0000000000..17d100367c --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/iterator-primitive.js @@ -0,0 +1,36 @@ +var BUGNUMBER = 1021835; +var summary = "Returning non-object from @@iterator should throw"; + +print(BUGNUMBER + ": " + summary); + +let primitives = [ + 1, + true, + undefined, + null, + "foo", + Symbol.iterator +]; + +function f([]) { +} + +for (let primitive of primitives) { + let obj = { + [Symbol.iterator]() { + return primitive; + } + }; + assertThrowsInstanceOf(() => { + let [] = obj; + }, TypeError); + assertThrowsInstanceOf(() => { + [] = obj; + }, TypeError); + assertThrowsInstanceOf(() => { + f(obj); + }, TypeError); +} + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/ecma_6/Destructuring/rest-with-trailing-comma.js b/js/src/tests/ecma_6/Destructuring/rest-with-trailing-comma.js new file mode 100644 index 0000000000..310180e14b --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/rest-with-trailing-comma.js @@ -0,0 +1,45 @@ +/* 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 invalidSyntax = [ + "[...r, ]", + "[a, ...r, ]", + "[a = 0, ...r, ]", + "[[], ...r, ]", + "[[...r,]]", + "[[...r,], ]", + "[[...r,], a]", +]; + +const validSyntax = [ + "[, ]", + "[a, ]", + "[[], ]", +]; + +const destructuringForms = [ + a => `${a} = [];`, + a => `var ${a} = [];`, + a => `let ${a} = [];`, + a => `const ${a} = [];`, + a => `(${a}) => {};`, + a => `(${a} = []) => {};`, + a => `function f(${a}) {}`, +]; + +for (let invalid of invalidSyntax) { + for (let fn of destructuringForms) { + assertThrowsInstanceOf(() => Function(fn(invalid)), SyntaxError); + } +} + +for (let invalid of validSyntax) { + for (let fn of destructuringForms) { + Function(fn(invalid)); + } +} + + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/ecma_6/Destructuring/shell.js b/js/src/tests/ecma_6/Destructuring/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/shell.js diff --git a/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-function.js b/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-function.js new file mode 100644 index 0000000000..9f5eed8345 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-function.js @@ -0,0 +1,182 @@ +/* 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/. */ + + +// Destructuring binding patterns with var. +(function() { + var {a: yield} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); + + var {yield} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); + + var {yield = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + var {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + var {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + var {yield = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with let. +(function(){ + let {a: yield} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +})(); + +(function() { + let {yield} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +})(); + +(function() { + let {yield = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + let {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + let {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + let {yield = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with const. +(function() { + const {a: yield} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +})(); + +(function() { + const {yield} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +})(); + +(function() { + const {yield = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + const {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + const {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + const {yield = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns in parameters. +(function({a: yield} = {a: "yield-with-name"}) { + assertEq(yield, "yield-with-name"); +})(); + +(function({yield} = {yield: "yield-with-shorthand"}) { + assertEq(yield, "yield-with-shorthand"); +})(); + +(function({yield = 0} = {yield: "yield-with-coverinitname"}) { + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f({a: yield} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f({yield} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f({yield = 0} = {}) { } +`), SyntaxError); + + +// Destructuring assignment pattern. +(function() { + var a, yield; + + ({a: yield} = {a: "yield-with-name"}); + assertEq(yield, "yield-with-name"); + + ({yield} = {yield: "yield-with-shorthand"}); + assertEq(yield, "yield-with-shorthand"); + + ({yield = 0} = {yield: "yield-with-coverinitname"}); + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + ({a: yield} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + ({yield} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function f() { + ({yield = 0} = {}); + } +`), SyntaxError); + + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-generator.js b/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-generator.js new file mode 100644 index 0000000000..4423f8190f --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-generator.js @@ -0,0 +1,200 @@ +/* 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/. */ + + +// Destructuring binding patterns with var. +assertThrowsInstanceOf(() => eval(` + function* g() { + var {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + var {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + var {yield = 0} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + var {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + var {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + var {yield = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with let. +assertThrowsInstanceOf(() => eval(` + function* g() { + let {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + let {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + let {yield = 0} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + let {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + let {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + let {yield = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with const. +assertThrowsInstanceOf(() => eval(` + function* g() { + const {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + const {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + const {yield = 0} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + const {a: yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + const {yield} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + const {yield = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns in parameters. +assertThrowsInstanceOf(() => eval(` + function* g({a: yield} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g({yield} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g({yield = 0} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g({a: yield} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g({yield} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g({yield = 0} = {}) { } +`), SyntaxError); + + +// Destructuring assignment pattern. +assertThrowsInstanceOf(() => eval(` + function* g() { + ({a: yield} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + ({yield} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + function* g() { + ({yield = 0} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + ({a: yield} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + ({yield} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + function* g() { + ({yield = 0} = {}); + } +`), SyntaxError); + + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-script.js b/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-script.js new file mode 100644 index 0000000000..99b48dd417 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/yield-in-object-destr-script.js @@ -0,0 +1,123 @@ +/* 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/. */ + + +// Destructuring binding patterns with var. +var {a: yield} = {a: "yield-with-name"}; +assertEq(yield, "yield-with-name"); + +var {yield} = {yield: "yield-with-shorthand"}; +assertEq(yield, "yield-with-shorthand"); + +var {yield = 0} = {yield: "yield-with-coverinitname"}; +assertEq(yield, "yield-with-coverinitname"); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + var {a: yield} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + var {yield} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + var {yield = 0} = {}; +`), SyntaxError); + + +// Destructuring binding patterns with let. +{ + let {a: yield} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +} + +{ + let {yield} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +} + +{ + let {yield = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +} + +assertThrowsInstanceOf(() => eval(` + "use strict"; + let {a: yield} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + let {yield} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + let {yield = 0} = {}; +`), SyntaxError); + + +// Destructuring binding patterns with const. +{ + const {a: yield} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +} + +{ + const {yield} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +} + +{ + const {yield = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +} + +assertThrowsInstanceOf(() => eval(` + "use strict"; + const {a: yield} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + const {yield} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + const {yield = 0} = {}; +`), SyntaxError); + + +// Destructuring assignment pattern. +({a: yield} = {a: "yield-with-name"}); +assertEq(yield, "yield-with-name"); + +({yield} = {yield: "yield-with-shorthand"}); +assertEq(yield, "yield-with-shorthand"); + +({yield = 0} = {yield: "yield-with-coverinitname"}); +assertEq(yield, "yield-with-coverinitname"); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + ({a: yield} = {}); +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + ({yield} = {}); +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(` + "use strict"; + ({yield = 0} = {}); +`), SyntaxError); + + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-function.js b/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-function.js new file mode 100644 index 0000000000..349badeaf7 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-function.js @@ -0,0 +1,182 @@ +/* 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/. */ + + +// Destructuring binding patterns with var. +(function() { + var {a: yi\u0065ld} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); + + var {yi\u0065ld} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); + + var {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + var {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + var {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + var {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with let. +(function(){ + let {a: yi\u0065ld} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +})(); + +(function() { + let {yi\u0065ld} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +})(); + +(function() { + let {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + let {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + let {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + let {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with const. +(function() { + const {a: yi\u0065ld} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +})(); + +(function() { + const {yi\u0065ld} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +})(); + +(function() { + const {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + const {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + const {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + const {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns in parameters. +(function({a: yi\u0065ld} = {a: "yield-with-name"}) { + assertEq(yield, "yield-with-name"); +})(); + +(function({yi\u0065ld} = {yield: "yield-with-shorthand"}) { + assertEq(yield, "yield-with-shorthand"); +})(); + +(function({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}) { + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f({a: yi\u0065ld} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f({yi\u0065ld} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f({yi\u0065ld = 0} = {}) { } +`), SyntaxError); + + +// Destructuring assignment pattern. +(function() { + var a, yield; + + ({a: yi\u0065ld} = {a: "yield-with-name"}); + assertEq(yield, "yield-with-name"); + + ({yi\u0065ld} = {yield: "yield-with-shorthand"}); + assertEq(yield, "yield-with-shorthand"); + + ({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}); + assertEq(yield, "yield-with-coverinitname"); +})(); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + ({a: yi\u0065ld} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + ({yi\u0065ld} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function f() { + ({yi\u0065ld = 0} = {}); + } +`), SyntaxError); + + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-generator.js b/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-generator.js new file mode 100644 index 0000000000..faa3563914 --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-generator.js @@ -0,0 +1,200 @@ +/* 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/. */ + + +// Destructuring binding patterns with var. +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + var {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + var {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + var {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + var {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + var {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + var {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with let. +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + let {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + let {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + let {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + let {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + let {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + let {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns with const. +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + const {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + const {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + const {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + const {a: yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + const {yi\u0065ld} = {}; + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + const {yi\u0065ld = 0} = {}; + } +`), SyntaxError); + + +// Destructuring binding patterns in parameters. +assertThrowsInstanceOf(() => eval(String.raw` + function* g({a: yi\u0065ld} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g({yi\u0065ld} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g({yi\u0065ld = 0} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g({a: yi\u0065ld} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g({yi\u0065ld} = {}) { } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g({yi\u0065ld = 0} = {}) { } +`), SyntaxError); + + +// Destructuring assignment pattern. +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + ({a: yi\u0065ld} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + ({yi\u0065ld} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + function* g() { + ({yi\u0065ld = 0} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + ({a: yi\u0065ld} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + ({yi\u0065ld} = {}); + } +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + function* g() { + ({yi\u0065ld = 0} = {}); + } +`), SyntaxError); + + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-script.js b/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-script.js new file mode 100644 index 0000000000..65352a66cf --- /dev/null +++ b/js/src/tests/ecma_6/Destructuring/yield-with-escape-in-object-destr-script.js @@ -0,0 +1,123 @@ +/* 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/. */ + + +// Destructuring binding patterns with var. +var {a: yi\u0065ld} = {a: "yield-with-name"}; +assertEq(yield, "yield-with-name"); + +var {yi\u0065ld} = {yield: "yield-with-shorthand"}; +assertEq(yield, "yield-with-shorthand"); + +var {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; +assertEq(yield, "yield-with-coverinitname"); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + var {a: yi\u0065ld} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + var {yi\u0065ld} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + var {yi\u0065ld = 0} = {}; +`), SyntaxError); + + +// Destructuring binding patterns with let. +{ + let {a: yi\u0065ld} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +} + +{ + let {yi\u0065ld} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +} + +{ + let {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +} + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + let {a: yi\u0065ld} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + let {yi\u0065ld} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + let {yi\u0065ld = 0} = {}; +`), SyntaxError); + + +// Destructuring binding patterns with const. +{ + const {a: yi\u0065ld} = {a: "yield-with-name"}; + assertEq(yield, "yield-with-name"); +} + +{ + const {yi\u0065ld} = {yield: "yield-with-shorthand"}; + assertEq(yield, "yield-with-shorthand"); +} + +{ + const {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}; + assertEq(yield, "yield-with-coverinitname"); +} + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + const {a: yi\u0065ld} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + const {yi\u0065ld} = {}; +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + const {yi\u0065ld = 0} = {}; +`), SyntaxError); + + +// Destructuring assignment pattern. +({a: yi\u0065ld} = {a: "yield-with-name"}); +assertEq(yield, "yield-with-name"); + +({yi\u0065ld} = {yield: "yield-with-shorthand"}); +assertEq(yield, "yield-with-shorthand"); + +({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}); +assertEq(yield, "yield-with-coverinitname"); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + ({a: yi\u0065ld} = {}); +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + ({yi\u0065ld} = {}); +`), SyntaxError); + +assertThrowsInstanceOf(() => eval(String.raw` + "use strict"; + ({yi\u0065ld = 0} = {}); +`), SyntaxError); + + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); |