Skip to content

Commit afeb2ea

Browse files
test: try
1 parent 6e63a00 commit afeb2ea

File tree

3 files changed

+381
-8
lines changed

3 files changed

+381
-8
lines changed

src/ast.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,15 @@ AST.prototype.resolvePrecedence = function(result, parser) {
323323
result = buffer;
324324
}
325325
}
326-
} else if (
327-
result.kind === "silent" &&
328-
!result.expr.parenthesizedExpression
329-
) {
330-
if (result.expr.kind === 'assign') return result;
326+
} else if (result.kind === "silent" && !result.expr.parenthesizedExpression) {
327+
if (result.expr.kind === "assign") return result;
331328
// overall least precedence
332329
if (result.expr.right) {
333330
buffer = result.expr;
334331
result.expr = buffer.left;
335332
buffer.left = result;
336333
this.swapLocations(buffer, buffer.left, buffer.right, parser);
337-
result = buffer;
334+
result = buffer;
338335
}
339336
}
340337
return result;

test/snapshot/__snapshots__/try.test.js.snap

Lines changed: 341 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,219 @@ Program {
8080
}
8181
`;
8282

83-
exports[`boolean miltiple catch 1`] = `
83+
exports[`boolean fully qualified name #2 1`] = `
84+
Program {
85+
"children": Array [
86+
Try {
87+
"always": null,
88+
"body": Block {
89+
"children": Array [
90+
ExpressionStatement {
91+
"expression": Call {
92+
"arguments": Array [],
93+
"kind": "call",
94+
"what": ClassReference {
95+
"kind": "classreference",
96+
"name": "call",
97+
"resolution": "uqn",
98+
},
99+
},
100+
"kind": "expressionstatement",
101+
},
102+
],
103+
"kind": "block",
104+
},
105+
"catches": Array [
106+
Catch {
107+
"body": Block {
108+
"children": Array [
109+
ExpressionStatement {
110+
"expression": Call {
111+
"arguments": Array [],
112+
"kind": "call",
113+
"what": ClassReference {
114+
"kind": "classreference",
115+
"name": "do_something",
116+
"resolution": "uqn",
117+
},
118+
},
119+
"kind": "expressionstatement",
120+
},
121+
],
122+
"kind": "block",
123+
},
124+
"kind": "catch",
125+
"variable": Variable {
126+
"curly": false,
127+
"kind": "variable",
128+
"name": "e",
129+
},
130+
"what": Array [
131+
ClassReference {
132+
"kind": "classreference",
133+
"name": "\\\\Exception\\\\Foo",
134+
"resolution": "fqn",
135+
},
136+
],
137+
},
138+
],
139+
"kind": "try",
140+
},
141+
],
142+
"errors": Array [],
143+
"kind": "program",
144+
}
145+
`;
146+
147+
exports[`boolean fully qualified name 1`] = `
148+
Program {
149+
"children": Array [
150+
Try {
151+
"always": null,
152+
"body": Block {
153+
"children": Array [
154+
ExpressionStatement {
155+
"expression": Call {
156+
"arguments": Array [],
157+
"kind": "call",
158+
"what": ClassReference {
159+
"kind": "classreference",
160+
"name": "call",
161+
"resolution": "uqn",
162+
},
163+
},
164+
"kind": "expressionstatement",
165+
},
166+
],
167+
"kind": "block",
168+
},
169+
"catches": Array [
170+
Catch {
171+
"body": Block {
172+
"children": Array [
173+
ExpressionStatement {
174+
"expression": Call {
175+
"arguments": Array [],
176+
"kind": "call",
177+
"what": ClassReference {
178+
"kind": "classreference",
179+
"name": "do_something",
180+
"resolution": "uqn",
181+
},
182+
},
183+
"kind": "expressionstatement",
184+
},
185+
],
186+
"kind": "block",
187+
},
188+
"kind": "catch",
189+
"variable": Variable {
190+
"curly": false,
191+
"kind": "variable",
192+
"name": "e",
193+
},
194+
"what": Array [
195+
ClassReference {
196+
"kind": "classreference",
197+
"name": "\\\\Exception",
198+
"resolution": "fqn",
199+
},
200+
],
201+
},
202+
],
203+
"kind": "try",
204+
},
205+
],
206+
"errors": Array [],
207+
"kind": "program",
208+
}
209+
`;
210+
211+
exports[`boolean multiple catch #2 1`] = `
212+
Program {
213+
"children": Array [
214+
Try {
215+
"always": null,
216+
"body": Block {
217+
"children": Array [
218+
ExpressionStatement {
219+
"expression": Call {
220+
"arguments": Array [],
221+
"kind": "call",
222+
"what": ClassReference {
223+
"kind": "classreference",
224+
"name": "call",
225+
"resolution": "uqn",
226+
},
227+
},
228+
"kind": "expressionstatement",
229+
},
230+
],
231+
"kind": "block",
232+
},
233+
"catches": Array [
234+
Catch {
235+
"body": Block {
236+
"children": Array [
237+
ExpressionStatement {
238+
"expression": Call {
239+
"arguments": Array [],
240+
"kind": "call",
241+
"what": ClassReference {
242+
"kind": "classreference",
243+
"name": "do_something",
244+
"resolution": "uqn",
245+
},
246+
},
247+
"kind": "expressionstatement",
248+
},
249+
],
250+
"kind": "block",
251+
},
252+
"kind": "catch",
253+
"variable": Variable {
254+
"curly": false,
255+
"kind": "variable",
256+
"name": "e",
257+
},
258+
"what": Array [
259+
ClassReference {
260+
"kind": "classreference",
261+
"name": "MyException",
262+
"resolution": "uqn",
263+
},
264+
ClassReference {
265+
"kind": "classreference",
266+
"name": "Foo\\\\Exception",
267+
"resolution": "qn",
268+
},
269+
ClassReference {
270+
"kind": "classreference",
271+
"name": "\\\\Exception",
272+
"resolution": "fqn",
273+
},
274+
ClassReference {
275+
"kind": "classreference",
276+
"name": "\\\\Exception\\\\Foo",
277+
"resolution": "fqn",
278+
},
279+
ClassReference {
280+
"kind": "classreference",
281+
"name": "Exception",
282+
"resolution": "rn",
283+
},
284+
],
285+
},
286+
],
287+
"kind": "try",
288+
},
289+
],
290+
"errors": Array [],
291+
"kind": "program",
292+
}
293+
`;
294+
295+
exports[`boolean multiple catch 1`] = `
84296
Program {
85297
"children": Array [
86298
Try {
@@ -149,6 +361,134 @@ Program {
149361
}
150362
`;
151363

364+
exports[`boolean qualified name 1`] = `
365+
Program {
366+
"children": Array [
367+
Try {
368+
"always": null,
369+
"body": Block {
370+
"children": Array [
371+
ExpressionStatement {
372+
"expression": Call {
373+
"arguments": Array [],
374+
"kind": "call",
375+
"what": ClassReference {
376+
"kind": "classreference",
377+
"name": "call",
378+
"resolution": "uqn",
379+
},
380+
},
381+
"kind": "expressionstatement",
382+
},
383+
],
384+
"kind": "block",
385+
},
386+
"catches": Array [
387+
Catch {
388+
"body": Block {
389+
"children": Array [
390+
ExpressionStatement {
391+
"expression": Call {
392+
"arguments": Array [],
393+
"kind": "call",
394+
"what": ClassReference {
395+
"kind": "classreference",
396+
"name": "do_something",
397+
"resolution": "uqn",
398+
},
399+
},
400+
"kind": "expressionstatement",
401+
},
402+
],
403+
"kind": "block",
404+
},
405+
"kind": "catch",
406+
"variable": Variable {
407+
"curly": false,
408+
"kind": "variable",
409+
"name": "e",
410+
},
411+
"what": Array [
412+
ClassReference {
413+
"kind": "classreference",
414+
"name": "Foo\\\\Exception",
415+
"resolution": "qn",
416+
},
417+
],
418+
},
419+
],
420+
"kind": "try",
421+
},
422+
],
423+
"errors": Array [],
424+
"kind": "program",
425+
}
426+
`;
427+
428+
exports[`boolean relative name 1`] = `
429+
Program {
430+
"children": Array [
431+
Try {
432+
"always": null,
433+
"body": Block {
434+
"children": Array [
435+
ExpressionStatement {
436+
"expression": Call {
437+
"arguments": Array [],
438+
"kind": "call",
439+
"what": ClassReference {
440+
"kind": "classreference",
441+
"name": "call",
442+
"resolution": "uqn",
443+
},
444+
},
445+
"kind": "expressionstatement",
446+
},
447+
],
448+
"kind": "block",
449+
},
450+
"catches": Array [
451+
Catch {
452+
"body": Block {
453+
"children": Array [
454+
ExpressionStatement {
455+
"expression": Call {
456+
"arguments": Array [],
457+
"kind": "call",
458+
"what": ClassReference {
459+
"kind": "classreference",
460+
"name": "do_something",
461+
"resolution": "uqn",
462+
},
463+
},
464+
"kind": "expressionstatement",
465+
},
466+
],
467+
"kind": "block",
468+
},
469+
"kind": "catch",
470+
"variable": Variable {
471+
"curly": false,
472+
"kind": "variable",
473+
"name": "e",
474+
},
475+
"what": Array [
476+
ClassReference {
477+
"kind": "classreference",
478+
"name": "Exception",
479+
"resolution": "rn",
480+
},
481+
],
482+
},
483+
],
484+
"kind": "try",
485+
},
486+
],
487+
"errors": Array [],
488+
"kind": "program",
489+
}
490+
`;
491+
152492
exports[`boolean simple 1`] = `
153493
Program {
154494
"children": Array [

0 commit comments

Comments
 (0)