Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ and are here relicensed by their original author (Eemeli Aro) under the Unicode

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

- `syntax-errors.json` — An array of strings that should produce a Syntax Error or a Data Model Error when parsed.
- `syntax-errors.json` — An array of strings that should produce a Syntax Error when parsed.

- `data-model-errors.json` - An object with string keys and arrays of strings as values,
where each key is the name of an error and its value is array of strings that
should produce `error` when processed.
Error names are defined in ["MessageFormat 2.0 Errors"](../spec/errors.md) in the spec.

- `test-core.json` — An array of test cases that do not depend on any registry definitions.
Each test may include some of the following fields:
Expand Down
32 changes: 32 additions & 0 deletions test/data-model-errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
"Variant Key Mismatch": [
".match {$foo :x} * * {{foo}}",
".match {$foo :x} {$bar :x} * {{foo}}"
],
"Missing Fallback Variant": [
".match {:foo} 1 {{_}}",
".match {:foo} other {{_}}",
".match {:foo} {:bar} * 1 {{_}} 1 * {{_}}"
],
"Missing Selector Annotation": [
".match {$foo} one {{one}} * {{other}}",
".input {$foo} .match {$foo} one {{one}} * {{other}}",
".local $foo = {$bar} .match {$foo} one {{one}} * {{other}}"
],
"Duplicate Declaration": [
".input {$foo} .input {$foo} {{_}}",
".input {$foo} .local $foo = {42} {{_}}",
".local $foo = {42} .input {$foo} {{_}}",
".local $foo = {:unknown} .local $foo = {42} {{_}}",
".local $foo = {$bar} .local $bar = {42} {{_}}",
".local $foo = {$foo} {{_}}",
".local $foo = {$bar} .local $bar = {$baz} {{_}}",
".local $foo = {$bar :func} .local $bar = {$baz} {{_}}",
".local $foo = {42 :func opt=$foo} {{_}}",
".local $foo = {42 :func opt=$bar} .local $bar = {42} {{_}}",
],
"Duplicate Option Name": [
"bad {:placeholder option=x option=x}",
"bad {:placeholder ns:option=x ns:option=y}"
]
]
22 changes: 1 addition & 21 deletions test/syntax-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
"bad {:} placeholder",
"bad {\\u0000placeholder}",
"no-equal {|42| :number minimumFractionDigits 2}",
"bad {:placeholder option=x option=x}",
"bad {:placeholder ns:option=x ns:option=y}",
"bad {:placeholder option=}",
"bad {:placeholder option value}",
"bad {:placeholder option:value}",
Expand All @@ -41,33 +39,15 @@
"no {|placeholder| end",
"no {|literal} end",
"no {|literal or placeholder end",
".input {$foo} .input {$foo} {{_}}",
".input {$foo} .local $foo = {42} {{_}}",
".local $foo = {42} .input {$foo} {{_}}",
".local $foo = {:unknown} .local $foo = {42} {{_}}",
".local bar = {|foo|} {{_}}",
".local #bar = {|foo|} {{_}}",
".local $bar {|foo|} {{_}}",
".local $bar = |foo| {{_}}",
".local $foo = {$bar} .local $bar = {42} {{_}}",
".local $foo = {$foo} {{_}}",
".local $foo = {$bar} .local $bar = {$baz} {{_}}",
".local $foo = {$bar :func} .local $bar = {$baz} {{_}}",
".local $foo = {42 :func opt=$foo} {{_}}",
".local $foo = {42 :func opt=$bar} .local $bar = {42} {{_}}",
".match {#foo} * {{foo}}",
".match {} * {{foo}}",
".match {|foo| :x} {|bar| :x} ** {{foo}}",
".match * {{foo}}",
".match {|x| :x} * foo",
".match {|x| :x} * {{foo}} extra",
".match |x| * {{foo}}",
".match {:foo} 1 {{_}}",
".match {:foo} other {{_}}",
".match {:foo} {:bar} * 1 {{_}} 1 * {{_}}",
".match {$foo :x} * * {{foo}}",
".match {$foo :x} {$bar :x} * {{foo}}",
".match {$foo} one {{one}} * {{other}}",
".input {$foo} .match {$foo} one {{one}} * {{other}}",
".local $foo = {$bar} .match {$foo} one {{one}} * {{other}}"
".match |x| * {{foo}}"
]