Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compliance test for whitespace in JSON literal. #11

Merged
merged 5 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions tests/legacy/legacy_literal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
"given": {
"foo": [{"name": "a"}, {"name": "b"}],
"bar": {"baz": "qux"}
},
"cases": [
{
"expression": "`foo`",
"result": "foo"
},
{
"comment": "Double quotes must be escaped.",
"expression": "`foo\\\"quote`",
"result": "foo\"quote"
},
{
"expression": "`✓`",
"result": "✓"
},
{
"comment": "Double quote in literal",
"expression": "`foo\\\"bar`",
"result": "foo\"bar"
springcomp marked this conversation as resolved.
Show resolved Hide resolved
},
{
"expression": "`1\\``",
"result": "1`"
},
{
"comment": "Multiple literal expressions with escapes",
"expression": "`\\\\`.{a:`b`}",
"result": {"a": "b"}
}
]
},
{
"comment": "Literals",
"given": {"type": "object"},
"cases": [
{
"expression": "`foo`",
"result": "foo"
},
{
"expression": "` foo`",
"result": "foo"
},
{
"comment": "Literal on RHS of subexpr not allowed",
"expression": "foo.`bar`",
"error": "syntax"
}
]
}
]
35 changes: 35 additions & 0 deletions tests/literal.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,41 @@
"comment": "Literal on RHS of subexpr not allowed",
"expression": "foo.`\"bar\"`",
"error": "syntax"
},
{
"comment": "Literal with all valid leading and trailing JSON whitespace",
"expression": "` \t\n\r{\"foo\": true} \t\n\r`",
"result": {"foo": true}
},
{
"comment": "Literal with non-JSON whitespace U+000C FORM FEED",
springcomp marked this conversation as resolved.
Show resolved Hide resolved
"expression": "`0\f`",
"error": "syntax"
},
{
"comment": "Literal with non-JSON whitespace U+0085 NEXT LINE",
"expression": "`0\u0085`",
"error": "syntax"
},
{
"comment": "Literal with non-JSON whitespace U+00A0 NO-BREAK SPACE",
"expression": "`0\u00A0`",
"error": "syntax"
},
{
"comment": "Literal with non-JSON whitespace U+1680 OGHAM SPACE MARK",
"expression": "`0\u1680`",
"error": "syntax"
},
{
"comment": "Literal with non-JSON whitespace U+2028 LINE SEPARATOR",
"expression": "`0\u2028`",
"error": "syntax"
},
{
"comment": "Literal with non-JSON whitespace U+3000 IDEOGRAPHIC SPACE",
"expression": "`0\u3000`",
"error": "syntax"
}
]
},
Expand Down