Skip to content

Commit 87e09f8

Browse files
committed
Uplift more complete reference test fixtures.
This loops back to projectfluent/fluent#286.
1 parent af20ab9 commit 87e09f8

14 files changed

+276
-7
lines changed

fluent.syntax/tests/syntax/fixtures_reference/comments.ftl

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ foo = Foo
99
-term = Term
1010
1111
# Another standalone
12-
#
12+
#
1313
# with indent
1414
## Group Comment
1515
### Resource Comment
16+
17+
# Errors
18+
#error
19+
##error
20+
###error

fluent.syntax/tests/syntax/fixtures_reference/comments.json

+19
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@
5858
{
5959
"type": "ResourceComment",
6060
"content": "Resource Comment"
61+
},
62+
{
63+
"type": "Comment",
64+
"content": "Errors"
65+
},
66+
{
67+
"type": "Junk",
68+
"annotations": [],
69+
"content": "#error\n"
70+
},
71+
{
72+
"type": "Junk",
73+
"annotations": [],
74+
"content": "##error\n"
75+
},
76+
{
77+
"type": "Junk",
78+
"annotations": [],
79+
"content": "###error\n"
6180
}
6281
]
6382
}

fluent.syntax/tests/syntax/fixtures_reference/escaped_characters.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ backslash-in-string = {"\\"}
1212
mismatched-quote = {"\\""}
1313
# ERROR Unknown escape
1414
unknown-escape = {"\x"}
15+
# ERROR Multiline literal
16+
invalid-multiline-literal = {"
17+
"}
1518
1619
## Unicode escapes
1720
string-unicode-4digits = {"\u0041"}

fluent.syntax/tests/syntax/fixtures_reference/escaped_characters.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,16 @@
168168
{
169169
"type": "Junk",
170170
"annotations": [],
171-
"content": "unknown-escape = {\"\\x\"}\n\n"
171+
"content": "unknown-escape = {\"\\x\"}\n"
172+
},
173+
{
174+
"type": "Comment",
175+
"content": "ERROR Multiline literal"
176+
},
177+
{
178+
"type": "Junk",
179+
"annotations": [],
180+
"content": "invalid-multiline-literal = {\"\n \"}\n\n"
172181
},
173182
{
174183
"type": "GroupComment",

fluent.syntax/tests/syntax/fixtures_reference/messages.ftl

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ key04 =
1818
key05 =
1919
.attr1 = Attribute 1
2020
21+
no-whitespace=Value
22+
.attr1=Attribute 1
23+
24+
extra-whitespace = Value
25+
.attr1 = Attribute 1
26+
2127
key06 = {""}
2228
2329
# JUNK Missing value

fluent.syntax/tests/syntax/fixtures_reference/messages.json

+70
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,76 @@
205205
"content": " < whitespace >"
206206
}
207207
},
208+
{
209+
"type": "Message",
210+
"id": {
211+
"type": "Identifier",
212+
"name": "no-whitespace"
213+
},
214+
"value": {
215+
"type": "Pattern",
216+
"elements": [
217+
{
218+
"type": "TextElement",
219+
"value": "Value"
220+
}
221+
]
222+
},
223+
"attributes": [
224+
{
225+
"type": "Attribute",
226+
"id": {
227+
"type": "Identifier",
228+
"name": "attr1"
229+
},
230+
"value": {
231+
"type": "Pattern",
232+
"elements": [
233+
{
234+
"type": "TextElement",
235+
"value": "Attribute 1"
236+
}
237+
]
238+
}
239+
}
240+
],
241+
"comment": null
242+
},
243+
{
244+
"type": "Message",
245+
"id": {
246+
"type": "Identifier",
247+
"name": "extra-whitespace"
248+
},
249+
"value": {
250+
"type": "Pattern",
251+
"elements": [
252+
{
253+
"type": "TextElement",
254+
"value": "Value"
255+
}
256+
]
257+
},
258+
"attributes": [
259+
{
260+
"type": "Attribute",
261+
"id": {
262+
"type": "Identifier",
263+
"name": "attr1"
264+
},
265+
"value": {
266+
"type": "Pattern",
267+
"elements": [
268+
{
269+
"type": "TextElement",
270+
"value": "Attribute 1"
271+
}
272+
]
273+
}
274+
}
275+
],
276+
"comment": null
277+
},
208278
{
209279
"type": "Message",
210280
"id": {

fluent.syntax/tests/syntax/fixtures_reference/select_expressions.ftl

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ invalid-selector-term-variant =
2222
}
2323
2424
# ERROR Nested expressions are not valid selectors
25-
invalid-selector-select-expression =
25+
invalid-selector-nested-expression =
2626
{ { 3 } ->
2727
*[key] default
2828
}
2929
3030
# ERROR Select expressions are not valid selectors
31-
invalid-selector-nested-expression =
31+
invalid-selector-select-expression =
3232
{ { $sel ->
3333
*[key] value
3434
} ->
@@ -40,6 +40,11 @@ empty-variant =
4040
*[key] {""}
4141
}
4242
43+
reduced-whitespace =
44+
{FOO()->
45+
*[key] {""}
46+
}
47+
4348
nested-select =
4449
{ $sel ->
4550
*[one] { $sel ->

fluent.syntax/tests/syntax/fixtures_reference/select_expressions.json

+56-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
{
153153
"type": "Junk",
154154
"annotations": [],
155-
"content": "invalid-selector-select-expression =\n { { 3 } ->\n *[key] default\n }\n\n"
155+
"content": "invalid-selector-nested-expression =\n { { 3 } ->\n *[key] default\n }\n\n"
156156
},
157157
{
158158
"type": "Comment",
@@ -161,7 +161,7 @@
161161
{
162162
"type": "Junk",
163163
"annotations": [],
164-
"content": "invalid-selector-nested-expression =\n { { $sel ->\n *[key] value\n } ->\n *[key] default\n }\n\n"
164+
"content": "invalid-selector-select-expression =\n { { $sel ->\n *[key] value\n } ->\n *[key] default\n }\n\n"
165165
},
166166
{
167167
"type": "Message",
@@ -212,6 +212,60 @@
212212
"attributes": [],
213213
"comment": null
214214
},
215+
{
216+
"type": "Message",
217+
"id": {
218+
"type": "Identifier",
219+
"name": "reduced-whitespace"
220+
},
221+
"value": {
222+
"type": "Pattern",
223+
"elements": [
224+
{
225+
"type": "Placeable",
226+
"expression": {
227+
"type": "SelectExpression",
228+
"selector": {
229+
"type": "FunctionReference",
230+
"id": {
231+
"type": "Identifier",
232+
"name": "FOO"
233+
},
234+
"arguments": {
235+
"type": "CallArguments",
236+
"positional": [],
237+
"named": []
238+
}
239+
},
240+
"variants": [
241+
{
242+
"type": "Variant",
243+
"key": {
244+
"type": "Identifier",
245+
"name": "key"
246+
},
247+
"value": {
248+
"type": "Pattern",
249+
"elements": [
250+
{
251+
"type": "Placeable",
252+
"expression": {
253+
"value": "",
254+
"type": "StringLiteral"
255+
}
256+
}
257+
]
258+
},
259+
"default": true
260+
}
261+
]
262+
}
263+
}
264+
]
265+
},
266+
"attributes": [],
267+
"comment": null
268+
},
215269
{
216270
"type": "Message",
217271
"id": {

fluent.syntax/tests/syntax/fixtures_reference/select_indent.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ select-1tbs-indent = {
1515
select-allman-inline =
1616
{ $selector ->
1717
*[key] Value
18+
[other] Other
1819
}
1920

2021
select-allman-newline =

fluent.syntax/tests/syntax/fixtures_reference/select_indent.json

+17
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@
176176
]
177177
},
178178
"default": true
179+
},
180+
{
181+
"type": "Variant",
182+
"key": {
183+
"type": "Identifier",
184+
"name": "other"
185+
},
186+
"value": {
187+
"type": "Pattern",
188+
"elements": [
189+
{
190+
"type": "TextElement",
191+
"value": "Other"
192+
}
193+
]
194+
},
195+
"default": false
179196
}
180197
]
181198
}

fluent.syntax/tests/syntax/fixtures_reference/terms.ftl

+6
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@
2121
2222
# JUNK Missing =
2323
-term07
24+
25+
-term08=Value
26+
.attr=Attribute
27+
28+
-term09 = Value
29+
.attr = Attribute

fluent.syntax/tests/syntax/fixtures_reference/terms.json

+71-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,77 @@
100100
{
101101
"type": "Junk",
102102
"annotations": [],
103-
"content": "-term07\n"
103+
"content": "-term07\n\n"
104+
},
105+
{
106+
"type": "Term",
107+
"id": {
108+
"type": "Identifier",
109+
"name": "term08"
110+
},
111+
"value": {
112+
"type": "Pattern",
113+
"elements": [
114+
{
115+
"type": "TextElement",
116+
"value": "Value"
117+
}
118+
]
119+
},
120+
"attributes": [
121+
{
122+
"type": "Attribute",
123+
"id": {
124+
"type": "Identifier",
125+
"name": "attr"
126+
},
127+
"value": {
128+
"type": "Pattern",
129+
"elements": [
130+
{
131+
"type": "TextElement",
132+
"value": "Attribute"
133+
}
134+
]
135+
}
136+
}
137+
],
138+
"comment": null
139+
},
140+
{
141+
"type": "Term",
142+
"id": {
143+
"type": "Identifier",
144+
"name": "term09"
145+
},
146+
"value": {
147+
"type": "Pattern",
148+
"elements": [
149+
{
150+
"type": "TextElement",
151+
"value": "Value"
152+
}
153+
]
154+
},
155+
"attributes": [
156+
{
157+
"type": "Attribute",
158+
"id": {
159+
"type": "Identifier",
160+
"name": "attr"
161+
},
162+
"value": {
163+
"type": "Pattern",
164+
"elements": [
165+
{
166+
"type": "TextElement",
167+
"value": "Attribute"
168+
}
169+
]
170+
}
171+
}
172+
],
173+
"comment": null
104174
}
105175
]
106176
}

fluent.syntax/tests/syntax/fixtures_reference/zero_length.ftl

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Resource",
3+
"body": []
4+
}

0 commit comments

Comments
 (0)