Skip to content

Commit 14e484e

Browse files
Synced compiance tests
1 parent 1271bc2 commit 14e484e

File tree

5 files changed

+137
-16
lines changed

5 files changed

+137
-16
lines changed

tests/compliance/boolean.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@
205205
"given": {
206206
"one": 1,
207207
"two": 2,
208-
"three": 3
208+
"three": 3,
209+
"emptylist": [],
210+
"boolvalue": false
209211
},
210212
"cases": [
211213
{
@@ -236,6 +238,22 @@
236238
"expression": "one != two",
237239
"result": true
238240
},
241+
{
242+
"expression": "emptylist < one",
243+
"result": null
244+
},
245+
{
246+
"expression": "emptylist < nullvalue",
247+
"result": null
248+
},
249+
{
250+
"expression": "emptylist < boolvalue",
251+
"result": null
252+
},
253+
{
254+
"expression": "one < boolvalue",
255+
"result": null
256+
},
239257
{
240258
"expression": "one < two && three > one",
241259
"result": true

tests/compliance/functions.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
"expression": "avg(strings)",
8484
"error": "invalid-type"
8585
},
86+
{
87+
"expression": "avg(empty_list)",
88+
"result": null
89+
},
8690
{
8791
"expression": "ceil(`1.2`)",
8892
"result": 2
@@ -568,12 +572,12 @@
568572
"error": "invalid-arity"
569573
},
570574
{
571-
"description": "function projection on single arg function",
575+
"comment": "function projection on single arg function",
572576
"expression": "numbers[].to_string(@)",
573577
"result": ["-1", "3", "4", "5"]
574578
},
575579
{
576-
"description": "function projection on single arg function",
580+
"comment": "function projection on single arg function",
577581
"expression": "array[].to_number(@)",
578582
"result": [-1, 3, 4, 5, 100]
579583
}
@@ -591,7 +595,7 @@
591595
},
592596
"cases": [
593597
{
594-
"description": "function projection on variadic function",
598+
"comment": "function projection on variadic function",
595599
"expression": "foo[].not_null(f, e, d, c, b, a)",
596600
"result": ["b", "c", "d", "e", "f"]
597601
}
@@ -609,7 +613,7 @@
609613
},
610614
"cases": [
611615
{
612-
"description": "sort by field expression",
616+
"comment": "sort by field expression",
613617
"expression": "sort_by(people, &age)",
614618
"result": [
615619
{"age": 10, "age_str": "10", "bool": true, "name": 3},
@@ -630,7 +634,7 @@
630634
]
631635
},
632636
{
633-
"description": "sort by function expression",
637+
"comment": "sort by function expression",
634638
"expression": "sort_by(people, &to_number(age_str))",
635639
"result": [
636640
{"age": 10, "age_str": "10", "bool": true, "name": 3},
@@ -641,7 +645,7 @@
641645
]
642646
},
643647
{
644-
"description": "function projection on sort_by function",
648+
"comment": "function projection on sort_by function",
645649
"expression": "sort_by(people, &age)[].name",
646650
"result": [3, "a", "c", "b", "d"]
647651
},
@@ -689,6 +693,10 @@
689693
"expression": "max_by(people, &to_number(age_str))",
690694
"result": {"age": 50, "age_str": "50", "bool": false, "name": "d"}
691695
},
696+
{
697+
"expression": "max_by(`[]`, &age)",
698+
"result": null
699+
},
692700
{
693701
"expression": "min_by(people, &age)",
694702
"result": {"age": 10, "age_str": "10", "bool": true, "name": 3}
@@ -708,6 +716,10 @@
708716
{
709717
"expression": "min_by(people, &to_number(age_str))",
710718
"result": {"age": 10, "age_str": "10", "bool": true, "name": 3}
719+
},
720+
{
721+
"expression": "min_by(`[]`, &age)",
722+
"result": null
711723
}
712724
]
713725
}, {
@@ -729,7 +741,7 @@
729741
},
730742
"cases": [
731743
{
732-
"description": "stable sort order",
744+
"comment": "stable sort order",
733745
"expression": "sort_by(people, &age)",
734746
"result": [
735747
{"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/multiselect.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@
387387
"comment": "Nested multiselect",
388388
"expression": "[[*]]",
389389
"result": [[]]
390+
},
391+
{
392+
"comment": "Select on null",
393+
"expression": "missing.{foo: bar}",
394+
"result": null
390395
}
391396
]
392397
}

tests/compliance/syntax.json

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@
77
"result": null
88
},
99
{
10-
"expression": "foo.1",
11-
"error": "syntax"
10+
"expression": "foo",
11+
"result": null
1212
},
1313
{
14-
"expression": "foo.-11",
14+
"expression": "foo.1",
1515
"error": "syntax"
1616
},
1717
{
18-
"expression": "foo",
19-
"result": null
20-
},
21-
{
22-
"expression": "foo.",
18+
"expression": "foo.-11",
2319
"error": "syntax"
2420
},
2521
{
@@ -103,6 +99,14 @@
10399
{
104100
"expression": "!",
105101
"error": "syntax"
102+
},
103+
{
104+
"expression": "@=",
105+
"error": "syntax"
106+
},
107+
{
108+
"expression": "@``",
109+
"error": "syntax"
106110
}
107111
]
108112
},
@@ -116,6 +120,33 @@
116120
}
117121
]
118122
},
123+
{
124+
"comment": "Paren syntax errors",
125+
"given": {},
126+
"cases": [
127+
{
128+
"comment": "missing closing paren",
129+
"expression": "(@",
130+
"error": "syntax"
131+
}
132+
]
133+
},
134+
{
135+
"comment": "Function syntax errors",
136+
"given": {},
137+
"cases": [
138+
{
139+
"comment": "invalid start of function",
140+
"expression": "@(foo)",
141+
"error": "syntax"
142+
},
143+
{
144+
"comment": "function names cannot be quoted",
145+
"expression": "\"foo\"(bar)",
146+
"error": "syntax"
147+
}
148+
]
149+
},
119150
{
120151
"comment": "Wildcard syntax",
121152
"given": {"type": "object"},
@@ -199,6 +230,37 @@
199230
{
200231
"expression": "foo[#]",
201232
"error": "syntax"
233+
},
234+
{
235+
"comment": "missing rbracket for led wildcard index",
236+
"expression": "led[*",
237+
"error": "syntax"
238+
}
239+
]
240+
},
241+
{
242+
"comment": "slice syntax",
243+
"given": {},
244+
"cases": [
245+
{
246+
"comment": "slice expected colon or rbracket",
247+
"expression": "[:@]",
248+
"error": "syntax"
249+
},
250+
{
251+
"comment": "slice has too many colons",
252+
"expression": "[:::]",
253+
"error": "syntax"
254+
},
255+
{
256+
"comment": "slice expected number",
257+
"expression": "[:@:]",
258+
"error": "syntax"
259+
},
260+
{
261+
"comment": "slice expected number of colon",
262+
"expression": "[:1@]",
263+
"error": "syntax"
202264
}
203265
]
204266
},
@@ -402,6 +464,11 @@
402464
"comment": "Nested multi select",
403465
"expression": "{\"\\\\\":{\" \":*}}",
404466
"result": {"\\": {" ": ["object"]}}
467+
},
468+
{
469+
"comment": "Missing closing } after a valid nud",
470+
"expression": "{a: @",
471+
"error": "syntax"
405472
}
406473
]
407474
},
@@ -574,6 +641,11 @@
574641
"comment": "Two level flattened projection of a literal",
575642
"expression": "twolen[].threelen[].`\"bar\"`",
576643
"error": "syntax"
644+
},
645+
{
646+
"comment": "expects closing ]",
647+
"expression": "foo[? @ | @",
648+
"error": "syntax"
577649
}
578650
]
579651
},
@@ -592,6 +664,10 @@
592664
{
593665
"expression": "\"\\\\\"",
594666
"result": null
667+
},
668+
{
669+
"expression": "\"\\u\"",
670+
"error": "syntax"
595671
}
596672
]
597673
},

0 commit comments

Comments
 (0)