Skip to content

Commit

Permalink
Tests functions that return special nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed Dec 27, 2023
1 parent e5fd6fa commit d554778
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cts.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down Expand Up @@ -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.*')]",
Expand Down
16 changes: 16 additions & 0 deletions tests/filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]
}
]
}
12 changes: 12 additions & 0 deletions tests/functions/length.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
}
]
}

0 comments on commit d554778

Please sign in to comment.