Skip to content

Commit 165b112

Browse files
committed
Add test cases
1 parent cb4c768 commit 165b112

7 files changed

+714
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
//// [destructureCatchClause.ts]
2+
try {} catch ({ x }) { x }
3+
try {} catch ([ x ]) { x }
4+
5+
try {} catch ({ a: { x } }) { x }
6+
try {} catch ({ a: [ x ] }) { x }
7+
8+
try {} catch ([{ x }]) { x }
9+
try {} catch ([[ x ]]) { x }
10+
11+
try {} catch ({ a: { b: { c: { x }} }}) { x }
12+
13+
14+
try {} catch ({ x }: any) { x }
15+
try {} catch ([ x ]: any) { x }
16+
17+
try {} catch ({ a: { x } }: any) { x }
18+
try {} catch ({ a: [ x ] }: any) { x }
19+
20+
try {} catch ([{ x }]: any) { x }
21+
try {} catch ([[ x ]]: any) { x }
22+
23+
try {} catch ({ a: { b: { c: { x }} }}: any) { x }
24+
25+
26+
try {} catch ({ x }: unknown) { x }
27+
try {} catch ([ x ]: unknown) { x }
28+
29+
try {} catch ({ a: { x } }: unknown) { x }
30+
try {} catch ({ a: [ x ] }: unknown) { x }
31+
32+
try {} catch ([{ x }]: unknown) { x }
33+
try {} catch ([[ x ]]: unknown) { x }
34+
35+
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x }
36+
37+
38+
//// [destructureCatchClause.js]
39+
"use strict";
40+
try { }
41+
catch (_a) {
42+
var x = _a.x;
43+
x;
44+
}
45+
try { }
46+
catch (_b) {
47+
var x = _b[0];
48+
x;
49+
}
50+
try { }
51+
catch (_c) {
52+
var x = _c.a.x;
53+
x;
54+
}
55+
try { }
56+
catch (_d) {
57+
var x = _d.a[0];
58+
x;
59+
}
60+
try { }
61+
catch (_e) {
62+
var x = _e[0].x;
63+
x;
64+
}
65+
try { }
66+
catch (_f) {
67+
var x = _f[0][0];
68+
x;
69+
}
70+
try { }
71+
catch (_g) {
72+
var x = _g.a.b.c.x;
73+
x;
74+
}
75+
try { }
76+
catch (_h) {
77+
var x = _h.x;
78+
x;
79+
}
80+
try { }
81+
catch (_j) {
82+
var x = _j[0];
83+
x;
84+
}
85+
try { }
86+
catch (_k) {
87+
var x = _k.a.x;
88+
x;
89+
}
90+
try { }
91+
catch (_l) {
92+
var x = _l.a[0];
93+
x;
94+
}
95+
try { }
96+
catch (_m) {
97+
var x = _m[0].x;
98+
x;
99+
}
100+
try { }
101+
catch (_o) {
102+
var x = _o[0][0];
103+
x;
104+
}
105+
try { }
106+
catch (_p) {
107+
var x = _p.a.b.c.x;
108+
x;
109+
}
110+
try { }
111+
catch (_q) {
112+
var x = _q.x;
113+
x;
114+
}
115+
try { }
116+
catch (_r) {
117+
var x = _r[0];
118+
x;
119+
}
120+
try { }
121+
catch (_s) {
122+
var x = _s.a.x;
123+
x;
124+
}
125+
try { }
126+
catch (_t) {
127+
var x = _t.a[0];
128+
x;
129+
}
130+
try { }
131+
catch (_u) {
132+
var x = _u[0].x;
133+
x;
134+
}
135+
try { }
136+
catch (_v) {
137+
var x = _v[0][0];
138+
x;
139+
}
140+
try { }
141+
catch (_w) {
142+
var x = _w.a.b.c.x;
143+
x;
144+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
=== tests/cases/compiler/destructureCatchClause.ts ===
2+
try {} catch ({ x }) { x }
3+
>x : Symbol(x, Decl(destructureCatchClause.ts, 0, 15))
4+
>x : Symbol(x, Decl(destructureCatchClause.ts, 0, 15))
5+
6+
try {} catch ([ x ]) { x }
7+
>x : Symbol(x, Decl(destructureCatchClause.ts, 1, 15))
8+
>x : Symbol(x, Decl(destructureCatchClause.ts, 1, 15))
9+
10+
try {} catch ({ a: { x } }) { x }
11+
>a : Symbol(a)
12+
>x : Symbol(x, Decl(destructureCatchClause.ts, 3, 20))
13+
>x : Symbol(x, Decl(destructureCatchClause.ts, 3, 20))
14+
15+
try {} catch ({ a: [ x ] }) { x }
16+
>a : Symbol(a)
17+
>x : Symbol(x, Decl(destructureCatchClause.ts, 4, 20))
18+
>x : Symbol(x, Decl(destructureCatchClause.ts, 4, 20))
19+
20+
try {} catch ([{ x }]) { x }
21+
>x : Symbol(x, Decl(destructureCatchClause.ts, 6, 16))
22+
>x : Symbol(x, Decl(destructureCatchClause.ts, 6, 16))
23+
24+
try {} catch ([[ x ]]) { x }
25+
>x : Symbol(x, Decl(destructureCatchClause.ts, 7, 16))
26+
>x : Symbol(x, Decl(destructureCatchClause.ts, 7, 16))
27+
28+
try {} catch ({ a: { b: { c: { x }} }}) { x }
29+
>a : Symbol(a)
30+
>b : Symbol(b)
31+
>c : Symbol(c)
32+
>x : Symbol(x, Decl(destructureCatchClause.ts, 9, 30))
33+
>x : Symbol(x, Decl(destructureCatchClause.ts, 9, 30))
34+
35+
36+
try {} catch ({ x }: any) { x }
37+
>x : Symbol(x, Decl(destructureCatchClause.ts, 12, 15))
38+
>x : Symbol(x, Decl(destructureCatchClause.ts, 12, 15))
39+
40+
try {} catch ([ x ]: any) { x }
41+
>x : Symbol(x, Decl(destructureCatchClause.ts, 13, 15))
42+
>x : Symbol(x, Decl(destructureCatchClause.ts, 13, 15))
43+
44+
try {} catch ({ a: { x } }: any) { x }
45+
>x : Symbol(x, Decl(destructureCatchClause.ts, 15, 20))
46+
>x : Symbol(x, Decl(destructureCatchClause.ts, 15, 20))
47+
48+
try {} catch ({ a: [ x ] }: any) { x }
49+
>x : Symbol(x, Decl(destructureCatchClause.ts, 16, 20))
50+
>x : Symbol(x, Decl(destructureCatchClause.ts, 16, 20))
51+
52+
try {} catch ([{ x }]: any) { x }
53+
>x : Symbol(x, Decl(destructureCatchClause.ts, 18, 16))
54+
>x : Symbol(x, Decl(destructureCatchClause.ts, 18, 16))
55+
56+
try {} catch ([[ x ]]: any) { x }
57+
>x : Symbol(x, Decl(destructureCatchClause.ts, 19, 16))
58+
>x : Symbol(x, Decl(destructureCatchClause.ts, 19, 16))
59+
60+
try {} catch ({ a: { b: { c: { x }} }}: any) { x }
61+
>x : Symbol(x, Decl(destructureCatchClause.ts, 21, 30))
62+
>x : Symbol(x, Decl(destructureCatchClause.ts, 21, 30))
63+
64+
65+
try {} catch ({ x }: unknown) { x }
66+
>x : Symbol(x, Decl(destructureCatchClause.ts, 24, 15))
67+
>x : Symbol(x, Decl(destructureCatchClause.ts, 24, 15))
68+
69+
try {} catch ([ x ]: unknown) { x }
70+
>x : Symbol(x, Decl(destructureCatchClause.ts, 25, 15))
71+
>x : Symbol(x, Decl(destructureCatchClause.ts, 25, 15))
72+
73+
try {} catch ({ a: { x } }: unknown) { x }
74+
>x : Symbol(x, Decl(destructureCatchClause.ts, 27, 20))
75+
>x : Symbol(x, Decl(destructureCatchClause.ts, 27, 20))
76+
77+
try {} catch ({ a: [ x ] }: unknown) { x }
78+
>x : Symbol(x, Decl(destructureCatchClause.ts, 28, 20))
79+
>x : Symbol(x, Decl(destructureCatchClause.ts, 28, 20))
80+
81+
try {} catch ([{ x }]: unknown) { x }
82+
>x : Symbol(x, Decl(destructureCatchClause.ts, 30, 16))
83+
>x : Symbol(x, Decl(destructureCatchClause.ts, 30, 16))
84+
85+
try {} catch ([[ x ]]: unknown) { x }
86+
>x : Symbol(x, Decl(destructureCatchClause.ts, 31, 16))
87+
>x : Symbol(x, Decl(destructureCatchClause.ts, 31, 16))
88+
89+
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x }
90+
>x : Symbol(x, Decl(destructureCatchClause.ts, 33, 30))
91+
>x : Symbol(x, Decl(destructureCatchClause.ts, 33, 30))
92+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
=== tests/cases/compiler/destructureCatchClause.ts ===
2+
try {} catch ({ x }) { x }
3+
>x : any
4+
>x : any
5+
6+
try {} catch ([ x ]) { x }
7+
>x : any
8+
>x : any
9+
10+
try {} catch ({ a: { x } }) { x }
11+
>a : any
12+
>x : any
13+
>x : any
14+
15+
try {} catch ({ a: [ x ] }) { x }
16+
>a : any
17+
>x : any
18+
>x : any
19+
20+
try {} catch ([{ x }]) { x }
21+
>x : any
22+
>x : any
23+
24+
try {} catch ([[ x ]]) { x }
25+
>x : any
26+
>x : any
27+
28+
try {} catch ({ a: { b: { c: { x }} }}) { x }
29+
>a : any
30+
>b : any
31+
>c : any
32+
>x : any
33+
>x : any
34+
35+
36+
try {} catch ({ x }: any) { x }
37+
>x : any
38+
>x : any
39+
40+
try {} catch ([ x ]: any) { x }
41+
>x : any
42+
>x : any
43+
44+
try {} catch ({ a: { x } }: any) { x }
45+
>a : any
46+
>x : any
47+
>x : any
48+
49+
try {} catch ({ a: [ x ] }: any) { x }
50+
>a : any
51+
>x : any
52+
>x : any
53+
54+
try {} catch ([{ x }]: any) { x }
55+
>x : any
56+
>x : any
57+
58+
try {} catch ([[ x ]]: any) { x }
59+
>x : any
60+
>x : any
61+
62+
try {} catch ({ a: { b: { c: { x }} }}: any) { x }
63+
>a : any
64+
>b : any
65+
>c : any
66+
>x : any
67+
>x : any
68+
69+
70+
try {} catch ({ x }: unknown) { x }
71+
>x : any
72+
>x : any
73+
74+
try {} catch ([ x ]: unknown) { x }
75+
>x : any
76+
>x : any
77+
78+
try {} catch ({ a: { x } }: unknown) { x }
79+
>a : any
80+
>x : any
81+
>x : any
82+
83+
try {} catch ({ a: [ x ] }: unknown) { x }
84+
>a : any
85+
>x : any
86+
>x : any
87+
88+
try {} catch ([{ x }]: unknown) { x }
89+
>x : any
90+
>x : any
91+
92+
try {} catch ([[ x ]]: unknown) { x }
93+
>x : any
94+
>x : any
95+
96+
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x }
97+
>a : any
98+
>b : any
99+
>c : any
100+
>x : any
101+
>x : any
102+

0 commit comments

Comments
 (0)