From 3eb6c86e7c86dc191d00e02d53909cc9245e1592 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Tue, 3 Sep 2024 19:19:27 +0300 Subject: [PATCH] Miscellaneous test fixes (#862) * Add missing expected bad-selector errors * Fix expected parts for unsupported-statement test * Add a few new tests for leading-whitespace and duplicate-variant * Add tests for escaped-char changes made in #743 * Fix tests for attributes with variable values --- test/tests/data-model-errors.json | 4 +++ test/tests/syntax-errors.json | 3 ++ test/tests/syntax.json | 58 +++++++++++++++++++++---------- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/test/tests/data-model-errors.json b/test/tests/data-model-errors.json index 86a674c43..bbc00fe80 100644 --- a/test/tests/data-model-errors.json +++ b/test/tests/data-model-errors.json @@ -180,6 +180,10 @@ "type": "duplicate-variant" } ] + }, + { + "src": ".match {star :string} |*| {{Literal star}} * {{The default}}", + "exp": "The default" } ] } diff --git a/test/tests/syntax-errors.json b/test/tests/syntax-errors.json index 34d9aa484..9f9f69e84 100644 --- a/test/tests/syntax-errors.json +++ b/test/tests/syntax-errors.json @@ -122,6 +122,9 @@ { "src": "bad {:placeholder @attribute=@foo}" }, + { + "src": "bad {:placeholder @attribute=$foo}" + }, { "src": "{ @misplaced = attribute }" }, diff --git a/test/tests/syntax.json b/test/tests/syntax.json index 1a2d601a2..1bde167eb 100644 --- a/test/tests/syntax.json +++ b/test/tests/syntax.json @@ -26,6 +26,11 @@ "src": "\\\\", "exp": "\\" }, + { + "description": "message -> simple-message -> simple-start pattern -> 1*escaped-char", + "src": "\\\\\\{\\|\\}", + "exp": "\\{|}" + }, { "description": "message -> simple-message -> simple-start pattern -> simple-start-char pattern -> ... -> simple-start-char *text-char placeholder", "src": "hello {world}", @@ -174,7 +179,7 @@ "description": "message -> complex-message -> complex-body -> matcher -> match-statement variant -> match selector key quoted-pattern -> \".match\" expression literal quoted-pattern", "src": ".match{a :f}a{{}}*{{}}", "exp": "", - "expErrors": [ { "type": "unknown-function" } ] + "expErrors": [{ "type": "unknown-function" }, { "type": "bad-selector" }] }, { "description": "... input-declaration -> input s variable-expression ...", @@ -196,35 +201,57 @@ "src": ".local $x = {a}{{}}", "exp": "" }, + { + "description": "input-declaration-like content in complex-message", + "src": "{{.input {$x}}}", + "params": [{ "name": "x", "value": "X" }], + "exp": ".input X" + }, + { + "description": "local-declaration-like content in complex-message with leading whitespace", + "src": "{{ .local $x = {$y}}}", + "params": [{ "name": "y", "value": "Y" }], + "exp": " .local $x = Y" + }, { "description": "... matcher -> match-statement [s] variant -> match 1*([s] selector) variant -> match selector selector variant -> match selector selector variant key s key quoted-pattern", "src": ".match{a :f}{b :f}a b{{}}* *{{}}", "exp": "", - "expErrors": [ { "type": "unknown-function" } ] + "expErrors": [ + { "type": "unknown-function" }, + { "type": "bad-selector" }, + { "type": "unknown-function" }, + { "type": "bad-selector" } + ] }, { "description": "... matcher -> match-statement [s] variant -> match 1*([s] selector) variant -> match selector variant variant ...", "src": ".match{a :f}a{{}}b{{}}*{{}}", "exp": "", - "expErrors": [ { "type": "unknown-function" } ] + "expErrors": [{ "type": "unknown-function" }, { "type": "bad-selector" }] }, { "description": "... variant -> key s quoted-pattern -> ...", "src": ".match{a :f}a {{}}*{{}}", "exp": "", - "expErrors": [ { "type": "unknown-function" } ] + "expErrors": [{ "type": "unknown-function" }, { "type": "bad-selector" }] }, { "description": "... variant -> key s key s quoted-pattern -> ...", "src": ".match{a :f}{b :f}a b {{}}* *{{}}", "exp": "", - "expErrors": [ { "type": "unknown-function" } ] + "expErrors": [ + { "type": "unknown-function" }, + { "type": "bad-selector" }, + { "type": "unknown-function" }, + { "type": "bad-selector" } + ] }, { "description": "... key -> \"*\" ...", "src": ".match{a :f}*{{}}", "exp": "", - "expErrors": [ { "type": "unknown-function" } ] + "expErrors": [{ "type": "unknown-function" }, { "type": "bad-selector" }] }, { "description": "simple-message -> simple-start pattern -> placeholder -> expression -> literal-expression -> \"{\" s literal \"}\"", @@ -399,8 +426,8 @@ "exp": "a" }, { - "description": "... attribute -> \"@\" identifier s \"=\" s variable ...", - "src": "{42 @foo=$bar}", + "description": "... attribute -> \"@\" identifier s \"=\" s quoted-literal ...", + "src": "{42 @foo=|bar|}", "exp": "42", "expParts": [ { @@ -426,9 +453,9 @@ "exp": "\\" }, { - "description": "... quoted-literal -> \"|\" quoted-char escaped-char \"|\"", - "src": "{|a\\\\|}", - "exp": "a\\" + "description": "... quoted-literal -> \"|\" quoted-char 1*escaped-char \"|\"", + "src": "{|a\\\\\\{\\|\\}|}", + "exp": "a\\{|}" }, { "description": "... unquoted-literal -> number-literal -> %x30", @@ -832,7 +859,7 @@ ] }, { - "src": "foo {?reserved @a @b=$c}", + "src": "foo {?reserved @a @b=c}", "exp": "foo {?}", "expParts": [ { @@ -898,12 +925,7 @@ { "src": ".l $y = {|bar|} {{}}", "exp": "", - "expParts": [ - { - "type": "literal", - "value": "bar" - } - ], + "expParts": [], "expErrors": [ { "type": "unsupported-statement"