From d7aeb990609a0aacfe712d272bef9db8f530df52 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 3 Apr 2024 12:06:41 -0700 Subject: [PATCH 1/2] Change format of test/data-model-errors.json file Previously, this file was not valid JSON. Added braces and updated README file accordingly. --- test/README.md | 5 +++-- test/data-model-errors.json | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/README.md b/test/README.md index b049946d2e..f6caf97188 100644 --- a/test/README.md +++ b/test/README.md @@ -5,8 +5,9 @@ These test files are intended to be useful for testing multiple different messag - `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 +- `data-model-errors.json` - An array of objects. + Each object has exactly one key, which is the name of the error, `error`. + The key's value is an array of strings that should produce `error` when processed. Error names are defined in ["MessageFormat 2.0 Errors"](../spec/errors.md) in the spec. diff --git a/test/data-model-errors.json b/test/data-model-errors.json index 3c7f1c9b88..5c59362eef 100644 --- a/test/data-model-errors.json +++ b/test/data-model-errors.json @@ -1,19 +1,23 @@ [ - "Variant Key Mismatch": [ + { + "Variant Key Mismatch": [ ".match {$foo :x} * * {{foo}}", ".match {$foo :x} {$bar :x} * {{foo}}" - ], - "Missing Fallback Variant": [ + ]}, + { + "Missing Fallback Variant": [ ".match {:foo} 1 {{_}}", ".match {:foo} other {{_}}", ".match {:foo} {:bar} * 1 {{_}} 1 * {{_}}" - ], - "Missing Selector Annotation": [ + ]}, + { + "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": [ + ]}, + { + "Duplicate Declaration": [ ".input {$foo} .input {$foo} {{_}}", ".input {$foo} .local $foo = {42} {{_}}", ".local $foo = {42} .input {$foo} {{_}}", @@ -23,10 +27,11 @@ ".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} {{_}}", - ], + ".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}" - ] + ]} ] From 85b77f01e6f0805dd0c5238156d7147970203749 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 3 Apr 2024 14:50:32 -0700 Subject: [PATCH 2/2] Change format of test/data-model-errors.json file Previously, this file was not valid JSON. Replaced '['/']' with '{'/'}'. Also removed a trailing comma and corrected typo in README file. --- test/README.md | 5 ++--- test/data-model-errors.json | 27 +++++++++++---------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/test/README.md b/test/README.md index f6caf97188..e5a513ef66 100644 --- a/test/README.md +++ b/test/README.md @@ -5,9 +5,8 @@ These test files are intended to be useful for testing multiple different messag - `syntax-errors.json` — An array of strings that should produce a Syntax Error when parsed. -- `data-model-errors.json` - An array of objects. - Each object has exactly one key, which is the name of the error, `error`. - The key's value is an array of strings that +- `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 an array of strings that should produce `error` when processed. Error names are defined in ["MessageFormat 2.0 Errors"](../spec/errors.md) in the spec. diff --git a/test/data-model-errors.json b/test/data-model-errors.json index 5c59362eef..0a6bd67641 100644 --- a/test/data-model-errors.json +++ b/test/data-model-errors.json @@ -1,23 +1,19 @@ -[ - { - "Variant Key Mismatch": [ +{ + "Variant Key Mismatch": [ ".match {$foo :x} * * {{foo}}", ".match {$foo :x} {$bar :x} * {{foo}}" - ]}, - { - "Missing Fallback Variant": [ + ], + "Missing Fallback Variant": [ ".match {:foo} 1 {{_}}", ".match {:foo} other {{_}}", ".match {:foo} {:bar} * 1 {{_}} 1 * {{_}}" - ]}, - { - "Missing Selector Annotation": [ + ], + "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": [ + ], + "Duplicate Declaration": [ ".input {$foo} .input {$foo} {{_}}", ".input {$foo} .local $foo = {42} {{_}}", ".local $foo = {42} .input {$foo} {{_}}", @@ -28,10 +24,9 @@ ".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}" - ]} -] + ] +}