Skip to content

Commit

Permalink
Add a non-deterministic test not involving objects
Browse files Browse the repository at this point in the history
The non-determinism in this case arises because of the interleaving of
descendants allowed by RFC 9535 Section 2.5.2.2.

Note that there is more non-determinism in the ordering of descendants,
but much of this is removed by the applications of the child wildcard
([*]).

The list of the input node and its descendants (the result of ..
before [*] is applied) can be in any of these orders:

[[[[1]],[2]],[[1]],[1],[2],1,2]
[[[[1]],[2]],[[1]],[1],[2],2,1]
[[[[1]],[2]],[[1]],[1],1,[2],2]
[[[[1]],[2]],[[1]],[2],[1],1,2]
[[[[1]],[2]],[[1]],[2],[1],2,1]
[[[[1]],[2]],[[1]],[2],2,[1],1]

Notice that these all satisfy the rules in Section 2.5.2.2:

* nodes of any array are visited in array order, and
* nodes are visited before their descendants.

Ref: https://github.com/glyn/jsonpath-nondeterminism
  • Loading branch information
glyn committed Mar 12, 2024
1 parent 1d03dc6 commit 5e1ecce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@
1
]
},
{
"name": "descendant segment, wildcard selector, nested arrays",
"selector" : "$..[*]",
"document" : [[[1]],[2]],
"results": [
[[[1]],[2],[1],1,2],
[[[1]],[2],[1],2,1]
]
},
{
"name": "descendant segment, wildcard shorthand, object data",
"selector" : "$..*",
Expand Down

0 comments on commit 5e1ecce

Please sign in to comment.