1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Test __proto__ is destructuring binding initialization.
// __proto__ shorthand, no default.
{
let {__proto__} = {};
assertEq(__proto__, Object.prototype);
}
// __proto__ shorthand, with default.
{
let {__proto__ = 0} = {};
assertEq(__proto__, Object.prototype);
}
{
let {__proto__ = 0} = Object.create(null);
assertEq(__proto__, 0);
}
// __proto__ keyed, no default.
{
let {__proto__: p} = {};
assertEq(p, Object.prototype);
}
// __proto__ keyed, with default.
{
let {__proto__: p = 0} = {};
assertEq(p, Object.prototype);
}
// __proto__ keyed, with default.
{
let {__proto__: p = 0} = Object.create(null);
assertEq(p, 0);
}
// Repeat the cases from above, but this time with a rest property.
// __proto__ shorthand, no default.
{
let {__proto__, ...rest} = {};
assertEq(__proto__, Object.prototype);
assertEq(Reflect.ownKeys(rest).length, 0);
}
// __proto__ shorthand, with default.
{
let {__proto__ = 0, ...rest} = {};
assertEq(__proto__, Object.prototype);
assertEq(Reflect.ownKeys(rest).length, 0);
}
{
let {__proto__ = 0, ...rest} = Object.create(null);
assertEq(__proto__, 0);
assertEq(Reflect.ownKeys(rest).length, 0);
}
// __proto__ keyed, no default.
{
let {__proto__: p, ...rest} = {};
assertEq(p, Object.prototype);
assertEq(Reflect.ownKeys(rest).length, 0);
}
// __proto__ keyed, with default.
{
let {__proto__: p = 0, ...rest} = {};
assertEq(p, Object.prototype);
assertEq(Reflect.ownKeys(rest).length, 0);
}
// __proto__ keyed, with default.
{
let {__proto__: p = 0, ...rest} = Object.create(null);
assertEq(p, 0);
assertEq(Reflect.ownKeys(rest).length, 0);
}
if (typeof reportCompare == "function")
reportCompare(true, true);
|