diff --git a/test/README.md b/test/README.md index 2469ce68f5..b049946d2e 100644 --- a/test/README.md +++ b/test/README.md @@ -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: diff --git a/test/data-model-errors.json b/test/data-model-errors.json new file mode 100644 index 0000000000..3c7f1c9b88 --- /dev/null +++ b/test/data-model-errors.json @@ -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}" + ] +] diff --git a/test/syntax-errors.json b/test/syntax-errors.json index c607e632e8..2d73b83961 100644 --- a/test/syntax-errors.json +++ b/test/syntax-errors.json @@ -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}", @@ -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}}" ]