| 1 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 |
|
| 5 |
|
| 6 |
// CoverInitName in arrow parameters. |
| 7 |
({a = 1}, {b = 2}, {c = 3}) => {}; |
| 8 |
({a = 1} = {}, {b = 2}, {c = 3}) => {}; |
| 9 |
({a = 1} = {}, {b = 2} = {}, {c = 3}) => {}; |
| 10 |
({a = 1} = {}, {b = 2} = {}, {c = 3} = {}) => {}; |
| 11 |
|
| 12 |
|
| 13 |
// CoverInitName in CoverParenthesizedExpressionAndArrowParameterList, |
| 14 |
// but not ArrowParameters. |
| 15 |
assertThrowsInstanceOf(() => eval(` |
| 16 |
({a = 1}, {b = 2}, {c = 3}); |
| 17 |
`), SyntaxError); |
| 18 |
assertThrowsInstanceOf(() => eval(` |
| 19 |
({a = 1}, {b = 2}, {c = 3} = {}); |
| 20 |
`), SyntaxError); |
| 21 |
assertThrowsInstanceOf(() => eval(` |
| 22 |
({a = 1}, {b = 2} = {}, {c = 3} = {}); |
| 23 |
`), SyntaxError); |
| 24 |
|
| 25 |
|
| 26 |
// CoverInitName nested in array destructuring. |
| 27 |
[{a = 0}] = [{}]; |
| 28 |
var [{a = 0}] = [{}]; |
| 29 |
{ let [{a = 0}] = [{}]; } |
| 30 |
{ const [{a = 0}] = [{}]; } |
| 31 |
|
| 32 |
for ([{a = 0}] of []); |
| 33 |
for (var [{a = 0}] of []); |
| 34 |
for (let [{a = 0}] of []); |
| 35 |
for (const [{a = 0}] of []); |
| 36 |
|
| 37 |
function f([{a = 0}]) {} |
| 38 |
var h = ([{a = 0}]) => {}; |
| 39 |
|
| 40 |
|
| 41 |
// CoverInitName nested in rest pattern. |
| 42 |
[...[{a = 0}]] = [{}]; |
| 43 |
var [...[{a = 0}]] = [{}]; |
| 44 |
{ let [...[{a = 0}]] = [{}]; } |
| 45 |
{ const [...[{a = 0}]] = [{}]; } |
| 46 |
|
| 47 |
for ([...[{a = 0}]] of []); |
| 48 |
for (var [...[{a = 0}]] of []); |
| 49 |
for (let [...[{a = 0}]] of []); |
| 50 |
for (const [...[{a = 0}]] of []); |
| 51 |
|
| 52 |
function f([...[{a = 0}]]) {} |
| 53 |
var h = ([...[{a = 0}]]) => {}; |
| 54 |
|
| 55 |
|
| 56 |
// CoverInitName nested in object destructuring. |
| 57 |
({p: {a = 0}} = {p: {}}); |
| 58 |
var {p: {a = 0}} = {p: {}}; |
| 59 |
{ let {p: {a = 0}} = {p: {}}; } |
| 60 |
{ const {p: {a = 0}} = {p: {}}; } |
| 61 |
|
| 62 |
for ({p: {a = 0}} of []); |
| 63 |
for (var {p: {a = 0}} of []); |
| 64 |
for (let {p: {a = 0}} of []); |
| 65 |
for (const {p: {a = 0}} of []); |
| 66 |
|
| 67 |
function f({p: {a = 0}}) {} |
| 68 |
var h = ({p: {a = 0}}) => {}; |
| 69 |
|
| 70 |
|
| 71 |
if (typeof reportCompare === "function") |
| 72 |
reportCompare(0, 0); |