Skip to content

Commit 2e91201

Browse files
committed
Test reference fixtures
1 parent c124158 commit 2e91201

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+7262
-6
lines changed

fluent/syntax/ast.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import json
44

55

6-
def to_json(value):
6+
def to_json(value, **kwargs):
77
if isinstance(value, BaseNode):
8-
return value.to_json()
8+
return value.to_json(**kwargs)
99
if isinstance(value, list):
10-
return list(map(to_json, value))
10+
return list(to_json(item, **kwargs) for item in value)
1111
if isinstance(value, tuple):
12-
return list(map(to_json, value))
12+
return list(to_json(item, **kwargs) for item in value)
1313
else:
1414
return value
1515

@@ -119,10 +119,11 @@ def equals(self, other, ignored_fields=['span']):
119119

120120
return True
121121

122-
def to_json(self):
122+
def to_json(self, with_spans=True):
123123
obj = {
124-
name: to_json(value)
124+
name: to_json(value, with_spans=with_spans)
125125
for name, value in vars(self).items()
126+
if with_spans or name != 'span'
126127
}
127128
obj.update(
128129
{'type': self.__class__.__name__}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ↓ BEL, U+0007
2+
control0 = abcdef
3+
4+
# ↓ DEL, U+007F
5+
delete = abcdef
6+
7+
# ↓ BPM, U+0082
8+
control1 = abc‚def
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"type": "Resource",
3+
"body": [
4+
{
5+
"type": "Message",
6+
"id": {
7+
"type": "Identifier",
8+
"name": "control0"
9+
},
10+
"value": {
11+
"type": "Pattern",
12+
"elements": [
13+
{
14+
"type": "TextElement",
15+
"value": "abc\u0007def"
16+
}
17+
]
18+
},
19+
"attributes": [],
20+
"comment": {
21+
"type": "Comment",
22+
"content": " ↓ BEL, U+0007"
23+
}
24+
},
25+
{
26+
"type": "Message",
27+
"id": {
28+
"type": "Identifier",
29+
"name": "delete"
30+
},
31+
"value": {
32+
"type": "Pattern",
33+
"elements": [
34+
{
35+
"type": "TextElement",
36+
"value": "abcdef"
37+
}
38+
]
39+
},
40+
"attributes": [],
41+
"comment": {
42+
"type": "Comment",
43+
"content": " ↓ DEL, U+007F"
44+
}
45+
},
46+
{
47+
"type": "Message",
48+
"id": {
49+
"type": "Identifier",
50+
"name": "control1"
51+
},
52+
"value": {
53+
"type": "Pattern",
54+
"elements": [
55+
{
56+
"type": "TextElement",
57+
"value": "abc‚def"
58+
}
59+
]
60+
},
61+
"attributes": [],
62+
"comment": {
63+
"type": "Comment",
64+
"content": " ↓ BPM, U+0082"
65+
}
66+
}
67+
]
68+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
face-with-tears-of-joy = 😂
2+
tetragram-for-centre = 𝌆
3+
4+
surrogates-in-text = \uD83D\uDE02
5+
surrogates-in-string = {"\uD83D\uDE02"}
6+
surrogates-in-adjacent-strings = {"\uD83D"}{"\uDE02"}
7+
8+
emoji-in-text = A face 😂 with tears of joy.
9+
emoji-in-string = {"A face 😂 with tears of joy."}
10+
11+
# ERROR Invalid identifier
12+
err-😂 = Value
13+
14+
# ERROR Invalid expression
15+
err-invalid-expression = { 😂 }
16+
17+
# ERROR Invalid variant key
18+
err-invalid-variant-key = { $sel ->
19+
*[😂] Value
20+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
{
2+
"type": "Resource",
3+
"body": [
4+
{
5+
"type": "Message",
6+
"id": {
7+
"type": "Identifier",
8+
"name": "face-with-tears-of-joy"
9+
},
10+
"value": {
11+
"type": "Pattern",
12+
"elements": [
13+
{
14+
"type": "TextElement",
15+
"value": "😂"
16+
}
17+
]
18+
},
19+
"attributes": [],
20+
"comment": null
21+
},
22+
{
23+
"type": "Message",
24+
"id": {
25+
"type": "Identifier",
26+
"name": "tetragram-for-centre"
27+
},
28+
"value": {
29+
"type": "Pattern",
30+
"elements": [
31+
{
32+
"type": "TextElement",
33+
"value": "𝌆"
34+
}
35+
]
36+
},
37+
"attributes": [],
38+
"comment": null
39+
},
40+
{
41+
"type": "Message",
42+
"id": {
43+
"type": "Identifier",
44+
"name": "surrogates-in-text"
45+
},
46+
"value": {
47+
"type": "Pattern",
48+
"elements": [
49+
{
50+
"type": "TextElement",
51+
"value": "\\uD83D\\uDE02"
52+
}
53+
]
54+
},
55+
"attributes": [],
56+
"comment": null
57+
},
58+
{
59+
"type": "Message",
60+
"id": {
61+
"type": "Identifier",
62+
"name": "surrogates-in-string"
63+
},
64+
"value": {
65+
"type": "Pattern",
66+
"elements": [
67+
{
68+
"type": "Placeable",
69+
"expression": {
70+
"type": "StringLiteral",
71+
"raw": "\\uD83D\\uDE02",
72+
"value": "��"
73+
}
74+
}
75+
]
76+
},
77+
"attributes": [],
78+
"comment": null
79+
},
80+
{
81+
"type": "Message",
82+
"id": {
83+
"type": "Identifier",
84+
"name": "surrogates-in-adjacent-strings"
85+
},
86+
"value": {
87+
"type": "Pattern",
88+
"elements": [
89+
{
90+
"type": "Placeable",
91+
"expression": {
92+
"type": "StringLiteral",
93+
"raw": "\\uD83D",
94+
"value": ""
95+
}
96+
},
97+
{
98+
"type": "Placeable",
99+
"expression": {
100+
"type": "StringLiteral",
101+
"raw": "\\uDE02",
102+
"value": ""
103+
}
104+
}
105+
]
106+
},
107+
"attributes": [],
108+
"comment": null
109+
},
110+
{
111+
"type": "Message",
112+
"id": {
113+
"type": "Identifier",
114+
"name": "emoji-in-text"
115+
},
116+
"value": {
117+
"type": "Pattern",
118+
"elements": [
119+
{
120+
"type": "TextElement",
121+
"value": "A face 😂 with tears of joy."
122+
}
123+
]
124+
},
125+
"attributes": [],
126+
"comment": null
127+
},
128+
{
129+
"type": "Message",
130+
"id": {
131+
"type": "Identifier",
132+
"name": "emoji-in-string"
133+
},
134+
"value": {
135+
"type": "Pattern",
136+
"elements": [
137+
{
138+
"type": "Placeable",
139+
"expression": {
140+
"type": "StringLiteral",
141+
"raw": "A face 😂 with tears of joy.",
142+
"value": "A face 😂 with tears of joy."
143+
}
144+
}
145+
]
146+
},
147+
"attributes": [],
148+
"comment": null
149+
},
150+
{
151+
"type": "Comment",
152+
"content": "ERROR Invalid identifier"
153+
},
154+
{
155+
"type": "Junk",
156+
"annotations": [],
157+
"content": "err-😂 = Value\n\n"
158+
},
159+
{
160+
"type": "Comment",
161+
"content": "ERROR Invalid expression"
162+
},
163+
{
164+
"type": "Junk",
165+
"annotations": [],
166+
"content": "err-invalid-expression = { 😂 }\n\n"
167+
},
168+
{
169+
"type": "Comment",
170+
"content": "ERROR Invalid variant key"
171+
},
172+
{
173+
"type": "Junk",
174+
"annotations": [],
175+
"content": "err-invalid-variant-key = { $sel ->\n *[😂] Value\n}\n"
176+
}
177+
]
178+
}

0 commit comments

Comments
 (0)