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

Introduce some tests of non-determinism #60

Merged
merged 8 commits into from
Mar 1, 2024
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
52 changes: 46 additions & 6 deletions cts.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@
"a": "A",
"b": "B"
},
"result": [
"A",
"B"
"results": [
[
"A",
"B"
],
[
"B",
"A"
]
]
},
{
Expand Down Expand Up @@ -135,9 +141,15 @@
"b": "By"
}
},
"result": [
"Ax",
"Ay"
"results": [
[
"Ax",
"Ay"
],
[
"Ay",
"Ax"
]
]
},
{
Expand Down Expand Up @@ -464,6 +476,34 @@
"f"
]
},
{
"name": "basic, descendant segment, object traversal, multiple selectors",
"selector": "$..['a','d']",
"document": {
"x": {
"a": "b",
"d": "e"
},
"y": {
"a": "c",
"d": "f"
}
},
"results": [
[
"b",
"e",
"c",
"f"
],
[
"c",
"f",
"b",
"e"
]
]
},
{
"name": "basic, bald descendant segment",
"selector": "$..",
Expand Down
13 changes: 13 additions & 0 deletions cts.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"result": {
"$ref": "#/$defs/test_case_result"
},
"results": {
"$ref": "#/$defs/test_case_results"
},
gregsdennis marked this conversation as resolved.
Show resolved Hide resolved
"invalid_selector": {
"$ref": "#/$defs/invalid_selector"
}
Expand All @@ -47,6 +50,12 @@
"result"
]
},
{
"required": [
"document",
"results"
]
},
{
"required": [
"invalid_selector"
Expand All @@ -63,6 +72,10 @@
"type": "array",
"description": "The expected result of applying the selector to the document, contains all the matched values"
},
"test_case_results": {
"type": "array",
gregsdennis marked this conversation as resolved.
Show resolved Hide resolved
"description": "An array of possible expected results of applying the selector to the document, each element of which contains all the matched values"
},
"selector": {
"description": "The JSONPath selector",
"type": "string"
Expand Down
30 changes: 26 additions & 4 deletions tests/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@
"a": "A",
"b": "B"
},
"result": [
"results": [[
"A",
"B"
]
],[
"B",
"A"
]]
},
{
"name": "wildcard shorthand, array data",
Expand Down Expand Up @@ -134,10 +137,13 @@
"b": "By"
}
},
"result": [
"results": [[
"Ax",
"Ay"
]
],[
"Ay",
"Ax"
]]
},
{
"name": "multiple selectors",
Expand Down Expand Up @@ -424,6 +430,22 @@
"f"
]
},
{
"name": "descendant segment, object traversal, multiple selectors",
"selector" : "$..['a','d']",
"document" : {"x": {"a": "b", "d": "e"}, "y": {"a":"c", "d": "f"}},
"results": [[
"b",
"e",
"c",
"f"
],[
"c",
"f",
"b",
"e"
]]
},
{
"name": "bald descendant segment",
"selector": "$..",
Expand Down
Loading