From 5e1ecce30e2c23354bc3fcc4eaf6ac2b008e4c7f Mon Sep 17 00:00:00 2001 From: Glyn Normington Date: Tue, 12 Mar 2024 12:51:07 +0000 Subject: [PATCH] Add a non-deterministic test not involving objects 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 --- tests/basic.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/basic.json b/tests/basic.json index ad9a719..2fb2340 100644 --- a/tests/basic.json +++ b/tests/basic.json @@ -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" : "$..*",