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

Add an edge case test that . matches \\u2029 and \\u2028 #35

Merged
merged 1 commit into from
May 8, 2024
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
64 changes: 64 additions & 0 deletions cts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3454,6 +3454,36 @@
"a𐄁b"
]
},
{
"name": "functions, match, dot matcher on \\u2028",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use \u2028 in the JSON document?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the question. Do you mean removing the second \? That would make the test name indistinguishable from the other one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was talking about using \u2028 in the "document" member.

Copy link
Collaborator Author

@f3ath f3ath Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the document it is defined as \u2028, you can see it in the source file. But it gets replaced with the actual character when the cts.json get compiled. I'm not sure if it would be possible to keep it as \uXXXX in the compiled cts.json.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's terribly important to have the character escaped in the doc. The only problem I could see is potentially a particularly strict JSON parser might not be able to read it.

"selector": "$[?match(@, '.')]",
"document": [
"
",
"\r",
"\n",
true,
[],
{}
],
"result": [
"
"
]
},
{
"name": "functions, match, dot matcher on \\u2029",
"selector": "$[?match(@, '.')]",
"document": [
"
",
"\r",
"\n",
true,
[],
{}
],
"result": [
"
"
]
},
{
"name": "functions, match, result cannot be compared",
"selector": "$[?match(@.a, 'a.*')==true]",
Expand Down Expand Up @@ -3650,6 +3680,40 @@
"a𐄁bc"
]
},
{
"name": "functions, search, dot matcher on \\u2028",
"selector": "$[?search(@, '.')]",
"document": [
"
",
"\r
\n",
"\r",
"\n",
true,
[],
{}
],
"result": [
"
",
"\r
\n"
]
},
{
"name": "functions, search, dot matcher on \\u2029",
"selector": "$[?search(@, '.')]",
"document": [
"
",
"\r
\n",
"\r",
"\n",
true,
[],
{}
],
"result": [
"
",
"\r
\n"
]
},
{
"name": "functions, search, result cannot be compared",
"selector": "$[?search(@.a, 'a.*')==true]",
Expand Down
12 changes: 12 additions & 0 deletions tests/functions/match.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
"document": ["a\uD800\uDD01b", "ab", "1", true, [], {}],
"result": ["a\uD800\uDD01b"]
},
{
"name": "dot matcher on \\u2028",
"selector": "$[?match(@, '.')]",
"document": ["\u2028", "\r", "\n", true, [], {}],
"result": ["\u2028"]
},
{
"name": "dot matcher on \\u2029",
"selector": "$[?match(@, '.')]",
"document": ["\u2029", "\r", "\n", true, [], {}],
"result": ["\u2029"]
},
{
"name": "result cannot be compared",
"selector" : "$[?match(@.a, 'a.*')==true]",
Expand Down
12 changes: 12 additions & 0 deletions tests/functions/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@
"document": ["a\uD800\uDD01bc", "abc", "1", true, [], {}],
"result": ["a\uD800\uDD01bc"]
},
{
"name": "dot matcher on \\u2028",
"selector": "$[?search(@, '.')]",
"document": ["\u2028", "\r\u2028\n", "\r", "\n", true, [], {}],
"result": ["\u2028", "\r\u2028\n"]
},
{
"name": "dot matcher on \\u2029",
"selector": "$[?search(@, '.')]",
"document": ["\u2029", "\r\u2029\n", "\r", "\n", true, [], {}],
"result": ["\u2029", "\r\u2029\n"]
},
{
"name": "result cannot be compared",
"selector" : "$[?search(@.a, 'a.*')==true]",
Expand Down