|
2 | 2 |
|
3 | 3 | exports[`Test strings binary cast 1`] = ` |
4 | 4 | Program { |
5 | | - "children": Array [ |
| 5 | + "children": [ |
6 | 6 | Echo { |
7 | | - "arguments": Array [ |
| 7 | + "expressions": [ |
8 | 8 | Cast { |
9 | | - "kind": "cast", |
10 | | - "type": "string", |
11 | | - "what": Encapsed { |
| 9 | + "expr": Encapsed { |
12 | 10 | "kind": "encapsed", |
13 | | - "raw": "\\"\\\\colors[1] contains >$colors[1]<\\\\n\\"", |
| 11 | + "raw": ""\\colors[1] contains >$colors[1]<\\n"", |
14 | 12 | "type": "string", |
15 | | - "value": Array [ |
16 | | - String { |
17 | | - "isDoubleQuote": false, |
18 | | - "kind": "string", |
19 | | - "raw": "\\\\colors[1] contains >", |
20 | | - "value": "\\\\colors[1] contains >", |
21 | | - }, |
22 | | - OffsetLookup { |
23 | | - "kind": "offsetlookup", |
24 | | - "offset": Number { |
25 | | - "kind": "number", |
26 | | - "value": "1", |
| 13 | + "value": [ |
| 14 | + EncapsedPart { |
| 15 | + "curly": false, |
| 16 | + "expression": String { |
| 17 | + "isDoubleQuote": false, |
| 18 | + "kind": "string", |
| 19 | + "raw": "\\colors[1] contains >", |
| 20 | + "unicode": false, |
| 21 | + "value": "\\colors[1] contains >", |
27 | 22 | }, |
28 | | - "what": Variable { |
29 | | - "byref": false, |
30 | | - "curly": false, |
31 | | - "kind": "variable", |
32 | | - "name": "colors", |
| 23 | + "kind": "encapsedpart", |
| 24 | + "syntax": null, |
| 25 | + }, |
| 26 | + EncapsedPart { |
| 27 | + "curly": false, |
| 28 | + "expression": OffsetLookup { |
| 29 | + "kind": "offsetlookup", |
| 30 | + "offset": Number { |
| 31 | + "kind": "number", |
| 32 | + "value": "1", |
| 33 | + }, |
| 34 | + "what": Variable { |
| 35 | + "curly": false, |
| 36 | + "kind": "variable", |
| 37 | + "name": "colors", |
| 38 | + }, |
33 | 39 | }, |
| 40 | + "kind": "encapsedpart", |
| 41 | + "syntax": "simple", |
34 | 42 | }, |
35 | | - String { |
36 | | - "isDoubleQuote": false, |
37 | | - "kind": "string", |
38 | | - "raw": "<\\\\n", |
39 | | - "value": "< |
| 43 | + EncapsedPart { |
| 44 | + "curly": false, |
| 45 | + "expression": String { |
| 46 | + "isDoubleQuote": false, |
| 47 | + "kind": "string", |
| 48 | + "raw": "<\\n", |
| 49 | + "unicode": false, |
| 50 | + "value": "< |
40 | 51 | ", |
| 52 | + }, |
| 53 | + "kind": "encapsedpart", |
| 54 | + "syntax": null, |
41 | 55 | }, |
42 | 56 | ], |
43 | 57 | }, |
| 58 | + "kind": "cast", |
| 59 | + "raw": "(binary)", |
| 60 | + "type": "binary", |
44 | 61 | }, |
45 | 62 | ], |
46 | 63 | "kind": "echo", |
47 | 64 | "shortForm": false, |
48 | 65 | }, |
49 | 66 | ], |
50 | | - "errors": Array [], |
| 67 | + "errors": [], |
51 | 68 | "kind": "program", |
52 | 69 | } |
53 | 70 | `; |
@@ -1314,7 +1331,8 @@ Program { |
1314 | 1331 | "kind": "string", |
1315 | 1332 | "raw": "\\n", |
1316 | 1333 | "unicode": false, |
1317 | | - "value": "", |
| 1334 | + "value": " |
| 1335 | +", |
1318 | 1336 | }, |
1319 | 1337 | "kind": "encapsedpart", |
1320 | 1338 | "syntax": null, |
@@ -1702,6 +1720,63 @@ Program { |
1702 | 1720 | } |
1703 | 1721 | `; |
1704 | 1722 |
|
| 1723 | +exports[`Test strings heredoc ... 1`] = ` |
| 1724 | +Program { |
| 1725 | + "children": [ |
| 1726 | + ExpressionStatement { |
| 1727 | + "expression": Assign { |
| 1728 | + "kind": "assign", |
| 1729 | + "left": Variable { |
| 1730 | + "curly": false, |
| 1731 | + "kind": "variable", |
| 1732 | + "name": "fallbackContent", |
| 1733 | + }, |
| 1734 | + "operator": ".=", |
| 1735 | + "right": Call { |
| 1736 | + "arguments": [ |
| 1737 | + Encapsed { |
| 1738 | + "kind": "encapsed", |
| 1739 | + "label": "EOF2", |
| 1740 | + "raw": "<<<EOF2 |
| 1741 | + \\$catalogue%s = new MessageCatalogue('%s', %s); |
| 1742 | + \\$catalogue%s->addFallbackCatalogue(\\$catalogue%s); |
| 1743 | + EOF2", |
| 1744 | + "type": "heredoc", |
| 1745 | + "value": [ |
| 1746 | + EncapsedPart { |
| 1747 | + "curly": false, |
| 1748 | + "expression": String { |
| 1749 | + "isDoubleQuote": false, |
| 1750 | + "kind": "string", |
| 1751 | + "raw": " \\$catalogue%s = new MessageCatalogue('%s', %s); |
| 1752 | + \\$catalogue%s->addFallbackCatalogue(\\$catalogue%s); |
| 1753 | + ", |
| 1754 | + "unicode": false, |
| 1755 | + "value": "$catalogue%s = new MessageCatalogue('%s', %s); |
| 1756 | +$catalogue%s->addFallbackCatalogue($catalogue%s);", |
| 1757 | + }, |
| 1758 | + "kind": "encapsedpart", |
| 1759 | + "syntax": null, |
| 1760 | + }, |
| 1761 | + ], |
| 1762 | + }, |
| 1763 | + ], |
| 1764 | + "kind": "call", |
| 1765 | + "what": Name { |
| 1766 | + "kind": "name", |
| 1767 | + "name": "sprintf", |
| 1768 | + "resolution": "uqn", |
| 1769 | + }, |
| 1770 | + }, |
| 1771 | + }, |
| 1772 | + "kind": "expressionstatement", |
| 1773 | + }, |
| 1774 | + ], |
| 1775 | + "errors": [], |
| 1776 | + "kind": "program", |
| 1777 | +} |
| 1778 | +`; |
| 1779 | +
|
1705 | 1780 | exports[`Test strings implement #116 1`] = ` |
1706 | 1781 | Program { |
1707 | 1782 | "children": [ |
@@ -1731,6 +1806,34 @@ bar", |
1731 | 1806 | } |
1732 | 1807 | `; |
1733 | 1808 |
|
| 1809 | +exports[`Test strings multiple escaped double quotes 1`] = ` |
| 1810 | +Program { |
| 1811 | + "children": [ |
| 1812 | + ExpressionStatement { |
| 1813 | + "expression": Assign { |
| 1814 | + "kind": "assign", |
| 1815 | + "left": Variable { |
| 1816 | + "curly": false, |
| 1817 | + "kind": "variable", |
| 1818 | + "name": "var", |
| 1819 | + }, |
| 1820 | + "operator": "=", |
| 1821 | + "right": String { |
| 1822 | + "isDoubleQuote": true, |
| 1823 | + "kind": "string", |
| 1824 | + "raw": ""say \\"hello\\" and \\"bye\\""", |
| 1825 | + "unicode": false, |
| 1826 | + "value": "say "hello" and "bye"", |
| 1827 | + }, |
| 1828 | + }, |
| 1829 | + "kind": "expressionstatement", |
| 1830 | + }, |
| 1831 | + ], |
| 1832 | + "errors": [], |
| 1833 | + "kind": "program", |
| 1834 | +} |
| 1835 | +`; |
| 1836 | +
|
1734 | 1837 | exports[`Test strings single (2) 1`] = ` |
1735 | 1838 | Program { |
1736 | 1839 | "children": [ |
@@ -2346,7 +2449,8 @@ Program { |
2346 | 2449 | "kind": "string", |
2347 | 2450 | "raw": "<\\n", |
2348 | 2451 | "unicode": false, |
2349 | | - "value": "<", |
| 2452 | + "value": "< |
| 2453 | +", |
2350 | 2454 | }, |
2351 | 2455 | "kind": "encapsedpart", |
2352 | 2456 | "syntax": null, |
|
0 commit comments