Skip to content

Commit a63c6a2

Browse files
committed
Add tests for fallback formatting
1 parent 65e902a commit a63c6a2

File tree

2 files changed

+58
-24
lines changed

2 files changed

+58
-24
lines changed

test/tests/fallback.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
3+
"scenario": "Fallback",
4+
"description": "Test cases for fallback behaviour.",
5+
"defaultTestProperties": {
6+
"bidiIsolation": "none",
7+
"locale": "en-US",
8+
"expErrors": true
9+
},
10+
"tests": [
11+
{
12+
"description": "function with unquoted literal operand",
13+
"src": "{42 :test:function fails=format}",
14+
"exp": "{|42|}"
15+
},
16+
{
17+
"description": "function with quoted literal operand",
18+
"src": "{|C:\\\\| :test:function fails=format}",
19+
"exp": "{|C:\\\\|}"
20+
},
21+
{
22+
"description": "unannotated implicit input variable",
23+
"src": "{$var}",
24+
"exp": "{$var}"
25+
},
26+
{
27+
"description": "annotated implicit input variable",
28+
"src": "{$var :number}",
29+
"exp": "{$var}"
30+
},
31+
{
32+
"description": "local variable with unknown function in declaration",
33+
"src": ".local $var = {|val| :test:undefined} {{{$var}}}",
34+
"exp": "{$var}"
35+
},
36+
{
37+
"description": "function with local variable operand with unknown function in declaration",
38+
"src": ".local $var = {|val| :test:undefined} {{{$var :test:function}}}",
39+
"exp": "{$var}"
40+
},
41+
{
42+
"description": "local variable with unknown function in placeholder",
43+
"src": ".local $var = {|val|} {{{$var :test:undefined}}}",
44+
"exp": "{$var}"
45+
},
46+
{
47+
"description": "function with no operand",
48+
"src": "{:test:undefined}",
49+
"exp": "{:test:undefined}"
50+
}
51+
]
52+
}

test/tests/functions/number.json

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -132,33 +132,15 @@
132132
},
133133
{
134134
"src": ".local $foo = {$bar :number minimumFractionDigits=foo} {{bar {$foo}}}",
135-
"params": [
136-
{
137-
"name": "bar",
138-
"value": 4.2
139-
}
140-
],
141-
"exp": "bar {$bar}",
142-
"expErrors": [
143-
{
144-
"type": "bad-option"
145-
}
146-
]
135+
"params": [{ "name": "bar", "value": 4.2 }],
136+
"exp": "bar {$foo}",
137+
"expErrors": [{ "type": "bad-option" }]
147138
},
148139
{
149140
"src": ".local $foo = {$bar :number} {{bar {$foo}}}",
150-
"params": [
151-
{
152-
"name": "bar",
153-
"value": "foo"
154-
}
155-
],
156-
"exp": "bar {$bar}",
157-
"expErrors": [
158-
{
159-
"type": "bad-operand"
160-
}
161-
]
141+
"params": [{ "name": "bar", "value": "foo" }],
142+
"exp": "bar {$foo}",
143+
"expErrors": [{ "type": "bad-operand" }]
162144
},
163145
{
164146
"src": ".input {$foo :number} {{bar {$foo}}}",

0 commit comments

Comments
 (0)