/
exec.js
62 lines (46 loc) 路 970 Bytes
/
exec.js
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
let [x = 23] = [,];
expect(x).toEqual(23);
const [y = 24, z] = [, 42];
expect(y).toEqual(24);
expect(z).toEqual(42);
function* foo() {
yield 1;
yield 2;
}
let bar = foo();
const [a = bar.next().value, b] = [, bar.next().value];
expect(a).toEqual(2);
expect(b).toEqual(1);
const arr = [c = 42] = [,];
expect(c).toEqual(42);
expect(arr).toStrictEqual([,]);
var iterCount = 0;
for (const [x = 23] = [,]; iterCount < 1; ) {
expect(x).toEqual(23);
// another statement
iterCount += 1;
}
expect(iterCount).toEqual(1);
const [...d] = [,];
const [...{ 0: e }] = [,];
expect(d).toStrictEqual([undefined,]);
expect(e).toEqual(undefined);
const [f] = [,];
expect(f).toEqual(undefined);
let [g] = [,];
expect(g).toEqual(undefined);
let thrown;
try {
thrown = false;
[{}] = [,];
} catch (e) {
thrown = true;
}
expect(thrown).toEqual(true);
try {
thrown = false;
[[]] = [,];
} catch (e) {
thrown = true;
}
expect(thrown).toEqual(true);