Skip to content

Commit da70f4e

Browse files
committed
Merge branch 'sync-tests' into develop
PR #284 * sync-tests: Sync upstream test from jmespath.test
2 parents 9eb120d + ebad302 commit da70f4e

File tree

5 files changed

+79
-7
lines changed

5 files changed

+79
-7
lines changed

tests/compliance/boolean.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@
188188
"expression": "!False && !EmptyList",
189189
"result": true
190190
},
191+
{
192+
"expression": "!True && False",
193+
"result": false
194+
},
191195
{
192196
"expression": "!(True && False)",
193197
"result": true

tests/compliance/filters.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,50 @@
8080
}
8181
]
8282
},
83+
{
84+
"given": {"foo": [{"weight": 33.3},
85+
{"weight": 44.4},
86+
{"weight": 55.5}]},
87+
"cases": [
88+
{
89+
"comment": "Greater than with a number",
90+
"expression": "foo[?weight > `44.4`]",
91+
"result": [{"weight": 55.5}]
92+
},
93+
{
94+
"expression": "foo[?weight >= `44.4`]",
95+
"result": [{"weight": 44.4}, {"weight": 55.5}]
96+
},
97+
{
98+
"comment": "Greater than with a number",
99+
"expression": "foo[?weight > `55.5`]",
100+
"result": []
101+
},
102+
{
103+
"comment": "Greater than with a number",
104+
"expression": "foo[?weight < `44.4`]",
105+
"result": [{"weight": 33.3}]
106+
},
107+
{
108+
"comment": "Greater than with a number",
109+
"expression": "foo[?weight <= `44.4`]",
110+
"result": [{"weight": 33.3}, {"weight": 44.4}]
111+
},
112+
{
113+
"comment": "Greater than with a number",
114+
"expression": "foo[?weight < `33.3`]",
115+
"result": []
116+
},
117+
{
118+
"expression": "foo[?weight == `33.3`]",
119+
"result": [{"weight": 33.3}]
120+
},
121+
{
122+
"expression": "foo[?weight != `33.3`]",
123+
"result": [{"weight": 44.4}, {"weight": 55.5}]
124+
}
125+
]
126+
},
83127
{
84128
"given": {"foo": [{"top": {"name": "a"}},
85129
{"top": {"name": "b"}}]},

tests/compliance/functions.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,12 @@
580580
"error": "invalid-arity"
581581
},
582582
{
583-
"description": "function projection on single arg function",
583+
"comment": "function projection on single arg function",
584584
"expression": "numbers[].to_string(@)",
585585
"result": ["-1", "3", "4", "5"]
586586
},
587587
{
588-
"description": "function projection on single arg function",
588+
"comment": "function projection on single arg function",
589589
"expression": "array[].to_number(@)",
590590
"result": [-1, 3, 4, 5, 100]
591591
}
@@ -603,7 +603,7 @@
603603
},
604604
"cases": [
605605
{
606-
"description": "function projection on variadic function",
606+
"comment": "function projection on variadic function",
607607
"expression": "foo[].not_null(f, e, d, c, b, a)",
608608
"result": ["b", "c", "d", "e", "f"]
609609
}
@@ -621,7 +621,7 @@
621621
},
622622
"cases": [
623623
{
624-
"description": "sort by field expression",
624+
"comment": "sort by field expression",
625625
"expression": "sort_by(people, &age)",
626626
"result": [
627627
{"age": 10, "age_str": "10", "bool": true, "name": 3},
@@ -642,7 +642,7 @@
642642
]
643643
},
644644
{
645-
"description": "sort by function expression",
645+
"comment": "sort by function expression",
646646
"expression": "sort_by(people, &to_number(age_str))",
647647
"result": [
648648
{"age": 10, "age_str": "10", "bool": true, "name": 3},
@@ -653,7 +653,7 @@
653653
]
654654
},
655655
{
656-
"description": "function projection on sort_by function",
656+
"comment": "function projection on sort_by function",
657657
"expression": "sort_by(people, &age)[].name",
658658
"result": [3, "a", "c", "b", "d"]
659659
},
@@ -749,7 +749,7 @@
749749
},
750750
"cases": [
751751
{
752-
"description": "stable sort order",
752+
"comment": "stable sort order",
753753
"expression": "sort_by(people, &age)",
754754
"result": [
755755
{"age": 10, "order": "1"},

tests/compliance/literal.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@
184184
"comment": "Can escape the single quote",
185185
"expression": "'foo\\'bar'",
186186
"result": "foo'bar"
187+
},
188+
{
189+
"comment": "Backslash not followed by single quote is treated as any other character",
190+
"expression": "'\\z'",
191+
"result": "\\z"
192+
},
193+
{
194+
"comment": "Backslash not followed by single quote is treated as any other character",
195+
"expression": "'\\\\'",
196+
"result": "\\\\"
187197
}
188198
]
189199
}

tests/compliance/syntax.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"expression": "foo.bar",
77
"result": null
88
},
9+
{
10+
"expression": "foo",
11+
"result": null
12+
},
913
{
1014
"expression": "foo.1",
1115
"error": "syntax"
@@ -416,6 +420,16 @@
416420
"expression": "a.{foo}",
417421
"error": "syntax"
418422
},
423+
{
424+
"comment": "Missing value",
425+
"expression": "a.{foo:}",
426+
"error": "syntax"
427+
},
428+
{
429+
"comment": "Missing value with trailing comma",
430+
"expression": "a.{foo: ,}",
431+
"error": "syntax"
432+
},
419433
{
420434
"comment": "Valid multi-select hash extraction",
421435
"expression": "a.{foo: bar}",

0 commit comments

Comments
 (0)