Skip to content

Commit

Permalink
Miscellaneous test fixes (#862)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eemeli authored Sep 3, 2024
1 parent 6657b80 commit 3eb6c86
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
4 changes: 4 additions & 0 deletions test/tests/data-model-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
"type": "duplicate-variant"
}
]
},
{
"src": ".match {star :string} |*| {{Literal star}} * {{The default}}",
"exp": "The default"
}
]
}
3 changes: 3 additions & 0 deletions test/tests/syntax-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
{
"src": "bad {:placeholder @attribute=@foo}"
},
{
"src": "bad {:placeholder @attribute=$foo}"
},
{
"src": "{ @misplaced = attribute }"
},
Expand Down
58 changes: 40 additions & 18 deletions test/tests/syntax.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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 ...",
Expand All @@ -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 \"}\"",
Expand Down Expand Up @@ -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": [
{
Expand All @@ -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",
Expand Down Expand Up @@ -832,7 +859,7 @@
]
},
{
"src": "foo {?reserved @a @b=$c}",
"src": "foo {?reserved @a @b=c}",
"exp": "foo {?}",
"expParts": [
{
Expand Down Expand Up @@ -898,12 +925,7 @@
{
"src": ".l $y = {|bar|} {{}}",
"exp": "",
"expParts": [
{
"type": "literal",
"value": "bar"
}
],
"expParts": [],
"expErrors": [
{
"type": "unsupported-statement"
Expand Down

0 comments on commit 3eb6c86

Please sign in to comment.