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 all 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
6 changes: 3 additions & 3 deletions bin/jp-compliance
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ComplianceTestRunner(object):
failure_message = (
"\nFAIL {category},{group_number},{test_number}\n"
"The expression: {expression}\n"
"was suppose to give: {result}\n"
"was supposed to give: {result}\n"
"for the JSON: {given_js}\n"
"but instead gave: {actual}\n"
).format(**test_case)
Expand All @@ -208,7 +208,7 @@ class ComplianceTestRunner(object):
failure_message = (
"\nFAIL {category},{group_number},{test_number}\n"
"The expression: {expression}\n"
"was suppose to have non zero for error error: {error}\n"
"was supposed to have non zero for error error: {error}\n"
"but instead gave rc of: {returncode}, stderr: \n{stderr}\n"
).format(**test_case)
sys.stdout.write(failure_message)
Expand All @@ -218,7 +218,7 @@ class ComplianceTestRunner(object):
failure_message = (
"\nFAIL {category},{group_number},{test_number}\n"
"The expression: {expression}\n"
"was suppose to emit the error: {error}\n"
"was supposed to emit the error: {error}\n"
"but instead gave: \n{stderr}\n"
).format(**test_case)
sys.stdout.write(failure_message)
Expand Down
39 changes: 39 additions & 0 deletions tests/jep-12/jep-12-literal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
{
"comment": "Literals",
"given": {
"type": "object"
},
"cases": [
{
"expression": "`foo`",
"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"
}
]
}
]
89 changes: 89 additions & 0 deletions tests/legacy/legacy-literal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[
{
"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": "✓"
},
{
"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"
springcomp marked this conversation as resolved.
Show resolved Hide resolved
},
{
"comment": "Literal on RHS of subexpr not allowed",
"expression": "foo.`bar`",
"error": "syntax"
},
{
"comment": "Literal with non-JSON whitespace U+0085 NEXT LINE",
"expression": "`0\u0085`",
"result": "0\u0085"
},
{
"comment": "Literal with non-JSON whitespace U+00A0 NO-BREAK SPACE",
"expression": "`0\u00A0`",
"result": "0\u00A0"
},
{
"comment": "Literal with non-JSON whitespace U+1680 OGHAM SPACE MARK",
"expression": "`0\u1680`",
"result": "0\u1680"
},
{
"comment": "Literal with non-JSON whitespace U+2028 LINE SEPARATOR",
"expression": "`0\u2028`",
"result": "0\u2028"
},
{
"comment": "Literal with non-JSON whitespace U+3000 IDEOGRAPHIC SPACE",
"expression": "`0\u3000`",
"result": "0\u3000"
}
]
}
]
Loading