Skip to content

Commit 9e595f6

Browse files
authored
Add tests for changes due to bidi/whitespace (#902)
* Add tests for changes due to bidi/whitespace * Correct output * Make erroneous test a syntax error
1 parent a93fcc1 commit 9e595f6

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

test/tests/bidi.json

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
{
2+
"scenario": "Bidi support",
3+
"description": "Tests for correct parsing of messages with bidirectional marks and isolates",
4+
"defaultTestProperties": {
5+
"locale": "en-US"
6+
},
7+
"tests": [
8+
{
9+
"description": "simple-message = o [simple-start pattern]",
10+
"src": " \u061C Hello world!",
11+
"exp": " \u061C Hello world!"
12+
},
13+
{
14+
"description": "complex-message = o *(declaration o) complex-body o",
15+
"src": "\u200E .local $x = {1} {{ {$x}}}",
16+
"exp": " 1"
17+
},
18+
{
19+
"description": "complex-message = o *(declaration o) complex-body o",
20+
"src": ".local $x = {1} \u200F {{ {$x}}}",
21+
"exp": " 1"
22+
},
23+
{
24+
"description": "complex-message = o *(declaration o) complex-body o",
25+
"src": ".local $x = {1} {{ {$x}}} \u2066",
26+
"exp": " 1"
27+
},
28+
{
29+
"description": "input-declaration = input o variable-expression",
30+
"src": ".input \u2067 {$x :number} {{hello}}",
31+
"params": [{"name": "x", "value": "1"}],
32+
"exp": "hello"
33+
},
34+
{
35+
"description": "local s variable o \"=\" o expression",
36+
"src": ".local $x \u2068 = \u2069 {1} {{hello}}",
37+
"exp": "hello"
38+
},
39+
{
40+
"description": "local s variable o \"=\" o expression",
41+
"src": ".local \u2067 $x = {1} {{hello}}",
42+
"exp": "hello"
43+
},
44+
{
45+
"description": "local s variable o \"=\" o expression",
46+
"src": ".local\u2067 $x = {1} {{hello}}",
47+
"exp": "hello"
48+
},
49+
{
50+
"description": "o \"{{\" pattern \"}}\"",
51+
"src": "\u2067 {{hello}}",
52+
"exp": "hello"
53+
},
54+
{
55+
"description": "match-statement s variant *(o variant)",
56+
"src": ".local $x = {1 :number}\n.match $x\n1 {{one}}\n\u061C * {{other}}",
57+
"exp": "one"
58+
},
59+
{
60+
"description": "match-statement s variant *(o variant)",
61+
"src": ".local $x = {1 :number}.match $x \u061c1 {{one}}* {{other}}",
62+
"exp": "one"
63+
},
64+
{
65+
"description": "match-statement s variant *(o variant)",
66+
"src": ".local $x = {1 :number}.match $x\u061c1 {{one}}* {{other}}",
67+
"expErrors": [{"type": "syntax-error"}]
68+
},
69+
{
70+
"description": "variant = key *(s key) quoted-pattern",
71+
"src": ".local $x = {1 :number} .local $y = {$x :number}.match $x $y\n1 \u200E 1 {{one}}* * {{other}}",
72+
"exp": "one"
73+
},
74+
{
75+
"description": "variant = key *(s key) quoted-pattern",
76+
"src": ".local $x = {1 :number} .local $y = {$x :number}.match $x $y\n1\u200E 1 {{one}}* * {{other}}",
77+
"exp": "one"
78+
},
79+
{
80+
"description": "literal-expression = \"{\" o literal [s function] *(s attribute) o \"}\"",
81+
"src": "{\u200E hello \u200F}",
82+
"exp": "hello"
83+
},
84+
{
85+
"description": "variable-expression = \"{\" o variable [s function] *(s attribute) o \"}\"",
86+
"src": ".local $x = {1} {{ {\u200E $x \u200F} }}",
87+
"exp": " 1 "
88+
},
89+
{
90+
"description": "function-expression = \"{\" o function *(s attribute) o \"}\"",
91+
"src": "{1 \u200E :number \u200F}",
92+
"exp": "1"
93+
},
94+
{
95+
"description": "markup = \"{\" o \"#\" identifier *(s option) *(s attribute) o [\"/\"] \"}\"",
96+
"src": "{\u200F #b \u200E }",
97+
"exp": ""
98+
},
99+
{
100+
"description": "markup = \"{\" o \"/\" identifier *(s option) *(s attribute) o \"}\"",
101+
"src": "{\u200F /b \u200E }",
102+
"exp": ""
103+
},
104+
{
105+
"description": "option = identifier o \"=\" o (literal / variable)",
106+
"src": "{1 :number minimumFractionDigits\u200F=\u200E1 }",
107+
"exp": "1.0"
108+
},
109+
{
110+
"description": "attribute = \"@\" identifier [o \"=\" o (literal / variable)]",
111+
"src": "{1 :number @locale\u200F=\u200Een }",
112+
"exp": "1"
113+
},
114+
{
115+
"description": " name... excludes U+FFFD and U+061C -- this pases as name -> [bidi] name-start *name-char",
116+
"src": ".local $\u061Cfoo = {1} {{ {$\u061Cfoo} }}",
117+
"exp": " 1 "
118+
},
119+
{
120+
"description": " name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName but excludes U+FFFD and U+061C",
121+
"src": ".local $foo\u061Cbar = {2} {{ }}",
122+
"expErrors": [{"type": "syntax-error"}]
123+
},
124+
{
125+
"description": "name = [bidi] name-start *name-char [bidi]",
126+
"src": ".local $\u200Efoo\u200F = {3} {{{$\u200Efoo\u200F}}}",
127+
"exp": "3"
128+
},
129+
{
130+
"description": "name = [bidi] name-start *name-char [bidi]",
131+
"src": ".local $foo = {4} {{{$\u200Efoo\u200F}}}",
132+
"exp": "4"
133+
},
134+
{
135+
"description": "name = [bidi] name-start *name-char [bidi]",
136+
"src": ".local $\u200Efoo\u200F = {5} {{{$foo}}}",
137+
"exp": "5"
138+
},
139+
{
140+
"description": "name = [bidi] name-start *name-char [bidi]",
141+
"src": ".local $foo\u200Ebar = {5} {{{$foo\u200Ebar}}}",
142+
"expErrors": [{"type": "syntax-error"}]
143+
}
144+
]
145+
}

0 commit comments

Comments
 (0)