Skip to content

Commit 74ee26f

Browse files
test: encapsed
1 parent ebc6ad4 commit 74ee26f

File tree

2 files changed

+272
-26
lines changed

2 files changed

+272
-26
lines changed

test/snapshot/__snapshots__/encapsed.test.js.snap

+260-26
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ Program {
193193
"expression": Variable {
194194
"curly": false,
195195
"kind": "variable",
196-
"name": Variable {
197-
"curly": false,
198-
"kind": "variable",
199-
"name": "juice",
200-
},
196+
"name": "juice",
201197
},
202198
"kind": "encapsedpart",
203199
"syntax": "simple",
@@ -248,16 +244,12 @@ Program {
248244
EncapsedPart {
249245
"curly": true,
250246
"expression": Variable {
251-
"curly": false,
247+
"curly": true,
252248
"kind": "variable",
253249
"name": Variable {
254-
"curly": true,
250+
"curly": false,
255251
"kind": "variable",
256-
"name": Variable {
257-
"curly": false,
258-
"kind": "variable",
259-
"name": "juice",
260-
},
252+
"name": "juice",
261253
},
262254
},
263255
"kind": "encapsedpart",
@@ -308,18 +300,260 @@ Program {
308300
},
309301
EncapsedPart {
310302
"curly": true,
311-
"expression": Variable {
312-
"curly": false,
313-
"kind": "variable",
314-
"name": Call {
315-
"arguments": Array [],
316-
"kind": "call",
317-
"what": ClassReference {
318-
"kind": "classreference",
319-
"name": "call",
320-
"resolution": "uqn",
303+
"expression": Call {
304+
"arguments": Array [],
305+
"kind": "call",
306+
"what": ClassReference {
307+
"kind": "classreference",
308+
"name": "call",
309+
"resolution": "uqn",
310+
},
311+
},
312+
"kind": "encapsedpart",
313+
"syntax": "simple",
314+
},
315+
EncapsedPart {
316+
"curly": false,
317+
"expression": String {
318+
"isDoubleQuote": false,
319+
"kind": "string",
320+
"raw": " string",
321+
"unicode": false,
322+
"value": " string",
323+
},
324+
"kind": "encapsedpart",
325+
"syntax": null,
326+
},
327+
],
328+
},
329+
"kind": "expressionstatement",
330+
},
331+
],
332+
"errors": Array [],
333+
"kind": "program",
334+
}
335+
`;
336+
337+
exports[`encapsed dollar open curly braces #5 1`] = `
338+
Program {
339+
"children": Array [
340+
ExpressionStatement {
341+
"expression": Encapsed {
342+
"kind": "encapsed",
343+
"raw": "\\"string \${test[test]} string\\"",
344+
"type": "string",
345+
"value": Array [
346+
EncapsedPart {
347+
"curly": false,
348+
"expression": String {
349+
"isDoubleQuote": false,
350+
"kind": "string",
351+
"raw": "string ",
352+
"unicode": false,
353+
"value": "string ",
354+
},
355+
"kind": "encapsedpart",
356+
"syntax": null,
357+
},
358+
EncapsedPart {
359+
"curly": true,
360+
"expression": OffsetLookup {
361+
"kind": "offsetlookup",
362+
"offset": ClassReference {
363+
"kind": "classreference",
364+
"name": "test",
365+
"resolution": "uqn",
366+
},
367+
"what": Variable {
368+
"curly": false,
369+
"kind": "variable",
370+
"name": "test",
371+
},
372+
},
373+
"kind": "encapsedpart",
374+
"syntax": "simple",
375+
},
376+
EncapsedPart {
377+
"curly": false,
378+
"expression": String {
379+
"isDoubleQuote": false,
380+
"kind": "string",
381+
"raw": " string",
382+
"unicode": false,
383+
"value": " string",
384+
},
385+
"kind": "encapsedpart",
386+
"syntax": null,
387+
},
388+
],
389+
},
390+
"kind": "expressionstatement",
391+
},
392+
],
393+
"errors": Array [],
394+
"kind": "program",
395+
}
396+
`;
397+
398+
exports[`encapsed dollar open curly braces #6 1`] = `
399+
Program {
400+
"children": Array [
401+
ExpressionStatement {
402+
"expression": Encapsed {
403+
"kind": "encapsed",
404+
"raw": "\\"string \${test[1]} string\\"",
405+
"type": "string",
406+
"value": Array [
407+
EncapsedPart {
408+
"curly": false,
409+
"expression": String {
410+
"isDoubleQuote": false,
411+
"kind": "string",
412+
"raw": "string ",
413+
"unicode": false,
414+
"value": "string ",
415+
},
416+
"kind": "encapsedpart",
417+
"syntax": null,
418+
},
419+
EncapsedPart {
420+
"curly": true,
421+
"expression": OffsetLookup {
422+
"kind": "offsetlookup",
423+
"offset": Number {
424+
"kind": "number",
425+
"value": "1",
426+
},
427+
"what": Variable {
428+
"curly": false,
429+
"kind": "variable",
430+
"name": "test",
431+
},
432+
},
433+
"kind": "encapsedpart",
434+
"syntax": "simple",
435+
},
436+
EncapsedPart {
437+
"curly": false,
438+
"expression": String {
439+
"isDoubleQuote": false,
440+
"kind": "string",
441+
"raw": " string",
442+
"unicode": false,
443+
"value": " string",
444+
},
445+
"kind": "encapsedpart",
446+
"syntax": null,
447+
},
448+
],
449+
},
450+
"kind": "expressionstatement",
451+
},
452+
],
453+
"errors": Array [],
454+
"kind": "program",
455+
}
456+
`;
457+
458+
exports[`encapsed dollar open curly braces #7 1`] = `
459+
Program {
460+
"children": Array [
461+
ExpressionStatement {
462+
"expression": Encapsed {
463+
"kind": "encapsed",
464+
"raw": "\\"string \${test[-1]} string\\"",
465+
"type": "string",
466+
"value": Array [
467+
EncapsedPart {
468+
"curly": false,
469+
"expression": String {
470+
"isDoubleQuote": false,
471+
"kind": "string",
472+
"raw": "string ",
473+
"unicode": false,
474+
"value": "string ",
475+
},
476+
"kind": "encapsedpart",
477+
"syntax": null,
478+
},
479+
EncapsedPart {
480+
"curly": true,
481+
"expression": OffsetLookup {
482+
"kind": "offsetlookup",
483+
"offset": Unary {
484+
"kind": "unary",
485+
"type": "-",
486+
"what": Number {
487+
"kind": "number",
488+
"value": "1",
321489
},
322490
},
491+
"what": Variable {
492+
"curly": false,
493+
"kind": "variable",
494+
"name": "test",
495+
},
496+
},
497+
"kind": "encapsedpart",
498+
"syntax": "simple",
499+
},
500+
EncapsedPart {
501+
"curly": false,
502+
"expression": String {
503+
"isDoubleQuote": false,
504+
"kind": "string",
505+
"raw": " string",
506+
"unicode": false,
507+
"value": " string",
508+
},
509+
"kind": "encapsedpart",
510+
"syntax": null,
511+
},
512+
],
513+
},
514+
"kind": "expressionstatement",
515+
},
516+
],
517+
"errors": Array [],
518+
"kind": "program",
519+
}
520+
`;
521+
522+
exports[`encapsed dollar open curly braces #8 1`] = `
523+
Program {
524+
"children": Array [
525+
ExpressionStatement {
526+
"expression": Encapsed {
527+
"kind": "encapsed",
528+
"raw": "\\"string \${test[$var]} string\\"",
529+
"type": "string",
530+
"value": Array [
531+
EncapsedPart {
532+
"curly": false,
533+
"expression": String {
534+
"isDoubleQuote": false,
535+
"kind": "string",
536+
"raw": "string ",
537+
"unicode": false,
538+
"value": "string ",
539+
},
540+
"kind": "encapsedpart",
541+
"syntax": null,
542+
},
543+
EncapsedPart {
544+
"curly": true,
545+
"expression": OffsetLookup {
546+
"kind": "offsetlookup",
547+
"offset": Variable {
548+
"curly": false,
549+
"kind": "variable",
550+
"name": "var",
551+
},
552+
"what": Variable {
553+
"curly": false,
554+
"kind": "variable",
555+
"name": "test",
556+
},
323557
},
324558
"kind": "encapsedpart",
325559
"syntax": "simple",
@@ -370,9 +604,9 @@ Program {
370604
EncapsedPart {
371605
"curly": true,
372606
"expression": Variable {
373-
"curly": false,
607+
"curly": "juice",
374608
"kind": "variable",
375-
"name": "juice",
609+
"name": "variable",
376610
},
377611
"kind": "encapsedpart",
378612
"syntax": "simple",
@@ -2620,9 +2854,9 @@ Program {
26202854
EncapsedPart {
26212855
"curly": true,
26222856
"expression": Variable {
2623-
"curly": false,
2857+
"curly": "var",
26242858
"kind": "variable",
2625-
"name": "var",
2859+
"name": "variable",
26262860
},
26272861
"kind": "encapsedpart",
26282862
"syntax": "simple",

test/snapshot/encapsed.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,18 @@ describe("encapsed", function() {
164164
it("dollar open curly braces #4", () => {
165165
expect(parser.parseEval('"string ${call()} string";')).toMatchSnapshot();
166166
});
167+
it("dollar open curly braces #5", () => {
168+
expect(parser.parseEval('"string ${test[test]} string";')).toMatchSnapshot();
169+
});
170+
it("dollar open curly braces #6", () => {
171+
expect(parser.parseEval('"string ${test[1]} string";')).toMatchSnapshot();
172+
});
173+
it("dollar open curly braces #7", () => {
174+
expect(parser.parseEval('"string ${test[-1]} string";')).toMatchSnapshot();
175+
});
176+
it("dollar open curly braces #8", () => {
177+
expect(parser.parseEval('"string ${test[$var]} string";')).toMatchSnapshot();
178+
});
167179
it("curly", () => {
168180
expect(parser.parseEval('"string {$juice} string";')).toMatchSnapshot();
169181
});

0 commit comments

Comments
 (0)