From d5547781465f5034bfd5969460209e56fce57d35 Mon Sep 17 00:00:00 2001 From: James Prior Date: Wed, 27 Dec 2023 15:00:03 +0000 Subject: [PATCH] Tests functions that return special nothing --- cts.json | 46 +++++++++++++++++++++++++++++++++++++ tests/filter.json | 16 +++++++++++++ tests/functions/length.json | 12 ++++++++++ 3 files changed, 74 insertions(+) diff --git a/cts.json b/cts.json index 34bad52..11af641 100644 --- a/cts.json +++ b/cts.json @@ -2397,6 +2397,32 @@ } ] }, + { + "name": "filter, equals, special nothing", + "selector": "$.values[?length(@.a) == value($..c)]", + "document": { + "c": "cd", + "values": [ + { + "a": "ab" + }, + { + "c": "d" + }, + { + "a": null + } + ] + }, + "result": [ + { + "c": "d" + }, + { + "a": null + } + ] + }, { "name": "index selector, first element", "selector": "$[0]", @@ -4110,6 +4136,26 @@ } ] }, + { + "name": "functions, length, arg is special nothing", + "selector": "$[?length(value(@.a))>0]", + "document": [ + { + "a": "ab" + }, + { + "c": "d" + }, + { + "a": null + } + ], + "result": [ + { + "a": "ab" + } + ] + }, { "name": "functions, match, found match", "selector": "$[?match(@.a, 'a.*')]", diff --git a/tests/filter.json b/tests/filter.json index c42160a..519bf21 100644 --- a/tests/filter.json +++ b/tests/filter.json @@ -770,6 +770,22 @@ "result": [ {"a": 0.011, "d": "e"} ] + }, + { + "name": "equals, special nothing", + "selector" : "$.values[?length(@.a) == value($..c)]", + "document" : { + "c": "cd", + "values": [ + {"a": "ab"}, + {"c": "d"}, + {"a": null} + ] + }, + "result": [ + {"c": "d"}, + {"a": null} + ] } ] } diff --git a/tests/functions/length.json b/tests/functions/length.json index 7213298..9382c2e 100644 --- a/tests/functions/length.json +++ b/tests/functions/length.json @@ -82,6 +82,18 @@ "result": [ {"a": "ab"} ] + }, + { + "name": "arg is special nothing", + "selector" : "$[?length(value(@.a))>0]", + "document" : [ + {"a": "ab"}, + {"c": "d"}, + {"a": null} + ], + "result": [ + {"a": "ab"} + ] } ] }