blob: 381076efe362d39d5ec6c7f0b62e7b236670c4cf (
plain)
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
|
String literals may be enclosed in single or double quotes.
Embedded escape sequences are started with a backslash, followed
by either a hexadecimal, an octal or a single character escape sequence.
-- Expect stdout --
Single quoted string
Double quoted string
Unicode escape sequence: ☀💩
Escaped double quote (") character
Escaped single quote (') character
Hexadecimal escape: XYZ xyz
Octal escape: ABC xyz
{ "Single char escape": "\u0007\b\u001b\f\r\t\u000b\\\n" }
-- End --
-- Testcase --
{{ 'Single quoted string' }}
{{ "Double quoted string" }}
{{ "Unicode escape sequence: \u2600\uD83D\uDCA9" }}
{{ "Escaped double quote (\") character" }}
{{ 'Escaped single quote (\') character' }}
{{ "Hexadecimal escape: \x58\x59\x5A \x78\x79\x7a" }}
{{ "Octal escape: \101\102\103 \170\171\172" }}
{{ { "Single char escape": "\a\b\e\f\r\t\v\\\n" } }}
-- End --
Testing various parsing corner cases.
-- Expect stdout --
[ "\t", "\n", "y" ]
-- End --
-- Testcase --
{%
print([
"\ ", // properly handle escaped tab
"\
", // properly handle escaped newline
"\y" // substitute unrecognized escape with escaped char
], "\n");
%}
-- End --
|