From 14f6fbe89eff35991ddf8f6ab4c09b917e0cbec2 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Tue, 20 Aug 2024 20:20:14 +0300 Subject: [PATCH 1/5] Add missing expected bad-selector errors --- test/tests/syntax.json | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/tests/syntax.json b/test/tests/syntax.json index 1a2d601a28..652d7850ee 100644 --- a/test/tests/syntax.json +++ b/test/tests/syntax.json @@ -174,7 +174,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 ...", @@ -200,31 +200,41 @@ "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 \"}\"", From 26ca17fe6822a8918fe54d220d3b81efed321b0e Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Tue, 20 Aug 2024 20:23:37 +0300 Subject: [PATCH 2/5] Fix expected parts for unsupported-statement test --- test/tests/syntax.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/tests/syntax.json b/test/tests/syntax.json index 652d7850ee..de74e737ed 100644 --- a/test/tests/syntax.json +++ b/test/tests/syntax.json @@ -908,12 +908,7 @@ { "src": ".l $y = {|bar|} {{}}", "exp": "", - "expParts": [ - { - "type": "literal", - "value": "bar" - } - ], + "expParts": [], "expErrors": [ { "type": "unsupported-statement" From 1e3d176ba9ac1b62bff0ed6ca46403f695a4216a Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Tue, 20 Aug 2024 21:13:39 +0300 Subject: [PATCH 3/5] Add a few new tests for leading-whitespace and duplicate-variant --- test/tests/data-model-errors.json | 4 ++++ test/tests/syntax.json | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/test/tests/data-model-errors.json b/test/tests/data-model-errors.json index 86a674c439..bbc00fe80f 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.json b/test/tests/syntax.json index de74e737ed..889e7ae4f8 100644 --- a/test/tests/syntax.json +++ b/test/tests/syntax.json @@ -196,6 +196,18 @@ "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{{}}* *{{}}", From 72f815c5ad39570cf693d67605ed06697f45eb50 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Wed, 21 Aug 2024 11:57:53 +0300 Subject: [PATCH 4/5] Add tests for escaped-char changes made in #743 --- test/tests/syntax.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/tests/syntax.json b/test/tests/syntax.json index 889e7ae4f8..43c3d7a792 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}", @@ -448,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", From e32955001f22e237558d95266913dd529fb305aa Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Wed, 21 Aug 2024 17:19:30 +0300 Subject: [PATCH 5/5] Fix tests for attributes with variable values --- test/tests/syntax-errors.json | 3 +++ test/tests/syntax.json | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/tests/syntax-errors.json b/test/tests/syntax-errors.json index 34d9aa4845..9f9f69e848 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 43c3d7a792..1bde167ebb 100644 --- a/test/tests/syntax.json +++ b/test/tests/syntax.json @@ -426,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": [ { @@ -859,7 +859,7 @@ ] }, { - "src": "foo {?reserved @a @b=$c}", + "src": "foo {?reserved @a @b=c}", "exp": "foo {?}", "expParts": [ {