Skip to content

Commit abc97d2

Browse files
catamorphismaphillipseemeli
authored
Separate data model errors from syntax errors (#708)
* Separate data model errors from syntax errors Split out data model errors into their own file and label tests according to the error name from the spec. No new test cases are added/removed. * Reformat data model error test file * Update test/syntax-errors.json Co-authored-by: Eemeli Aro <[email protected]> * Update test/README.md Co-authored-by: Eemeli Aro <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]> Co-authored-by: Eemeli Aro <[email protected]>
1 parent 07f6309 commit abc97d2

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

test/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ and are here relicensed by their original author (Eemeli Aro) under the Unicode
33

44
These test files are intended to be useful for testing multiple different message processors in different ways:
55

6-
- `syntax-errors.json` — An array of strings that should produce a Syntax Error or a Data Model Error when parsed.
6+
- `syntax-errors.json` — An array of strings that should produce a Syntax Error when parsed.
7+
8+
- `data-model-errors.json` - An object with string keys and arrays of strings as values,
9+
where each key is the name of an error and its value is array of strings that
10+
should produce `error` when processed.
11+
Error names are defined in ["MessageFormat 2.0 Errors"](../spec/errors.md) in the spec.
712

813
- `test-core.json` — An array of test cases that do not depend on any registry definitions.
914
Each test may include some of the following fields:

test/data-model-errors.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
"Variant Key Mismatch": [
3+
".match {$foo :x} * * {{foo}}",
4+
".match {$foo :x} {$bar :x} * {{foo}}"
5+
],
6+
"Missing Fallback Variant": [
7+
".match {:foo} 1 {{_}}",
8+
".match {:foo} other {{_}}",
9+
".match {:foo} {:bar} * 1 {{_}} 1 * {{_}}"
10+
],
11+
"Missing Selector Annotation": [
12+
".match {$foo} one {{one}} * {{other}}",
13+
".input {$foo} .match {$foo} one {{one}} * {{other}}",
14+
".local $foo = {$bar} .match {$foo} one {{one}} * {{other}}"
15+
],
16+
"Duplicate Declaration": [
17+
".input {$foo} .input {$foo} {{_}}",
18+
".input {$foo} .local $foo = {42} {{_}}",
19+
".local $foo = {42} .input {$foo} {{_}}",
20+
".local $foo = {:unknown} .local $foo = {42} {{_}}",
21+
".local $foo = {$bar} .local $bar = {42} {{_}}",
22+
".local $foo = {$foo} {{_}}",
23+
".local $foo = {$bar} .local $bar = {$baz} {{_}}",
24+
".local $foo = {$bar :func} .local $bar = {$baz} {{_}}",
25+
".local $foo = {42 :func opt=$foo} {{_}}",
26+
".local $foo = {42 :func opt=$bar} .local $bar = {42} {{_}}",
27+
],
28+
"Duplicate Option Name": [
29+
"bad {:placeholder option=x option=x}",
30+
"bad {:placeholder ns:option=x ns:option=y}"
31+
]
32+
]

test/syntax-errors.json

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
"bad {:} placeholder",
2424
"bad {\\u0000placeholder}",
2525
"no-equal {|42| :number minimumFractionDigits 2}",
26-
"bad {:placeholder option=x option=x}",
27-
"bad {:placeholder ns:option=x ns:option=y}",
2826
"bad {:placeholder option=}",
2927
"bad {:placeholder option value}",
3028
"bad {:placeholder option:value}",
@@ -44,33 +42,15 @@
4442
"no {|placeholder| end",
4543
"no {|literal} end",
4644
"no {|literal or placeholder end",
47-
".input {$foo} .input {$foo} {{_}}",
48-
".input {$foo} .local $foo = {42} {{_}}",
49-
".local $foo = {42} .input {$foo} {{_}}",
50-
".local $foo = {:unknown} .local $foo = {42} {{_}}",
5145
".local bar = {|foo|} {{_}}",
5246
".local #bar = {|foo|} {{_}}",
5347
".local $bar {|foo|} {{_}}",
5448
".local $bar = |foo| {{_}}",
55-
".local $foo = {$bar} .local $bar = {42} {{_}}",
56-
".local $foo = {$foo} {{_}}",
57-
".local $foo = {$bar} .local $bar = {$baz} {{_}}",
58-
".local $foo = {$bar :func} .local $bar = {$baz} {{_}}",
59-
".local $foo = {42 :func opt=$foo} {{_}}",
60-
".local $foo = {42 :func opt=$bar} .local $bar = {42} {{_}}",
6149
".match {#foo} * {{foo}}",
6250
".match {} * {{foo}}",
6351
".match {|foo| :x} {|bar| :x} ** {{foo}}",
6452
".match * {{foo}}",
6553
".match {|x| :x} * foo",
6654
".match {|x| :x} * {{foo}} extra",
67-
".match |x| * {{foo}}",
68-
".match {:foo} 1 {{_}}",
69-
".match {:foo} other {{_}}",
70-
".match {:foo} {:bar} * 1 {{_}} 1 * {{_}}",
71-
".match {$foo :x} * * {{foo}}",
72-
".match {$foo :x} {$bar :x} * {{foo}}",
73-
".match {$foo} one {{one}} * {{other}}",
74-
".input {$foo} .match {$foo} one {{one}} * {{other}}",
75-
".local $foo = {$bar} .match {$foo} one {{one}} * {{other}}"
55+
".match |x| * {{foo}}"
7656
]

0 commit comments

Comments
 (0)