Skip to content

Commit 2c579ba

Browse files
committed
Sync compliance tests with JEP 12 updates
1 parent 2726291 commit 2c579ba

File tree

4 files changed

+189
-98
lines changed

4 files changed

+189
-98
lines changed

tests/filters.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cases": [
55
{
66
"comment": "Matching a literal",
7-
"expression": "foo[?name == `a`]",
7+
"expression": "foo[?name == 'a']",
88
"result": [{"name": "a"}]
99
}
1010
]
@@ -86,7 +86,7 @@
8686
"cases": [
8787
{
8888
"comment": "Filter with subexpression",
89-
"expression": "foo[?top.name == `a`]",
89+
"expression": "foo[?top.name == 'a']",
9090
"result": [{"top": {"name": "a"}}]
9191
}
9292
]
@@ -294,5 +294,22 @@
294294
"result": []
295295
}
296296
]
297+
},
298+
{
299+
"given": {
300+
"foo": [
301+
{"a": 1, "b": {"c": "x"}},
302+
{"a": 1, "b": {"c": "y"}},
303+
{"a": 1, "b": {"c": "z"}},
304+
{"a": 2, "b": {"c": "z"}},
305+
{"a": 1, "baz": 2}
306+
]
307+
},
308+
"cases": [
309+
{
310+
"expression": "foo[?a==`1`].b.c",
311+
"result": ["x", "y", "z"]
312+
}
313+
]
297314
}
298315
]

tests/functions.json

Lines changed: 82 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"error": "invalid-type"
6969
},
7070
{
71-
"expression": "avg(`abc`)",
71+
"expression": "avg('abc')",
7272
"error": "invalid-type"
7373
},
7474
{
@@ -100,23 +100,23 @@
100100
"result": -1
101101
},
102102
{
103-
"expression": "ceil(`string`)",
103+
"expression": "ceil('string')",
104104
"error": "invalid-type"
105105
},
106106
{
107-
"expression": "contains(`abc`, `a`)",
107+
"expression": "contains('abc', 'a')",
108108
"result": true
109109
},
110110
{
111-
"expression": "contains(`abc`, `d`)",
111+
"expression": "contains('abc', 'd')",
112112
"result": false
113113
},
114114
{
115-
"expression": "contains(`false`, `d`)",
115+
"expression": "contains(`false`, 'd')",
116116
"error": "invalid-type"
117117
},
118118
{
119-
"expression": "contains(strings, `a`)",
119+
"expression": "contains(strings, 'a')",
120120
"result": true
121121
},
122122
{
@@ -128,23 +128,23 @@
128128
"result": false
129129
},
130130
{
131-
"expression": "ends_with(str, `r`)",
131+
"expression": "ends_with(str, 'r')",
132132
"result": true
133133
},
134134
{
135-
"expression": "ends_with(str, `tr`)",
135+
"expression": "ends_with(str, 'tr')",
136136
"result": true
137137
},
138138
{
139-
"expression": "ends_with(str, `Str`)",
139+
"expression": "ends_with(str, 'Str')",
140140
"result": true
141141
},
142142
{
143-
"expression": "ends_with(str, `SStr`)",
143+
"expression": "ends_with(str, 'SStr')",
144144
"result": false
145145
},
146146
{
147-
"expression": "ends_with(str, `foo`)",
147+
"expression": "ends_with(str, 'foo')",
148148
"result": false
149149
},
150150
{
@@ -156,7 +156,7 @@
156156
"result": 1
157157
},
158158
{
159-
"expression": "floor(`string`)",
159+
"expression": "floor('string')",
160160
"error": "invalid-type"
161161
},
162162
{
@@ -172,11 +172,11 @@
172172
"error": "invalid-type"
173173
},
174174
{
175-
"expression": "length(`abc`)",
175+
"expression": "length('abc')",
176176
"result": 3
177177
},
178178
{
179-
"expression": "length(`\"\"`)",
179+
"expression": "length('')",
180180
"result": 0
181181
},
182182
{
@@ -239,6 +239,26 @@
239239
"expression": "max(empty_list)",
240240
"result": null
241241
},
242+
{
243+
"expression": "merge(`{}`)",
244+
"result": {}
245+
},
246+
{
247+
"expression": "merge(`{}`, `{}`)",
248+
"result": {}
249+
},
250+
{
251+
"expression": "merge(`{\"a\": 1}`, `{\"b\": 2}`)",
252+
"result": {"a": 1, "b": 2}
253+
},
254+
{
255+
"expression": "merge(`{\"a\": 1}`, `{\"a\": 2}`)",
256+
"result": {"a": 2}
257+
},
258+
{
259+
"expression": "merge(`{\"a\": 1, \"b\": 2}`, `{\"a\": 2, \"c\": 3}`, `{\"d\": 4}`)",
260+
"result": {"a": 2, "b": 2, "c": 3, "d": 4}
261+
},
242262
{
243263
"expression": "min(numbers)",
244264
"result": -1
@@ -268,7 +288,7 @@
268288
"result": "a"
269289
},
270290
{
271-
"expression": "type(`abc`)",
291+
"expression": "type('abc')",
272292
"result": "string"
273293
},
274294
{
@@ -332,43 +352,43 @@
332352
"error": "invalid-type"
333353
},
334354
{
335-
"expression": "join(`\", \"`, strings)",
355+
"expression": "join(', ', strings)",
336356
"result": "a, b, c"
337357
},
338358
{
339-
"expression": "join(`, `, strings)",
359+
"expression": "join(', ', strings)",
340360
"result": "a, b, c"
341361
},
342362
{
343-
"expression": "join(`,`, `[\"a\", \"b\"]`)",
363+
"expression": "join(',', `[\"a\", \"b\"]`)",
344364
"result": "a,b"
345365
},
346366
{
347-
"expression": "join(`,`, `[\"a\", 0]`)",
367+
"expression": "join(',', `[\"a\", 0]`)",
348368
"error": "invalid-type"
349369
},
350370
{
351-
"expression": "join(`, `, str)",
371+
"expression": "join(', ', str)",
352372
"error": "invalid-type"
353373
},
354374
{
355-
"expression": "join(`|`, strings)",
375+
"expression": "join('|', strings)",
356376
"result": "a|b|c"
357377
},
358378
{
359379
"expression": "join(`2`, strings)",
360380
"error": "invalid-type"
361381
},
362382
{
363-
"expression": "join(`|`, decimals)",
383+
"expression": "join('|', decimals)",
364384
"error": "invalid-type"
365385
},
366386
{
367-
"expression": "join(`|`, decimals[].to_string(@))",
387+
"expression": "join('|', decimals[].to_string(@))",
368388
"result": "1.01|1.2|-1.5"
369389
},
370390
{
371-
"expression": "join(`|`, empty_list)",
391+
"expression": "join('|', empty_list)",
372392
"result": ""
373393
},
374394
{
@@ -384,27 +404,27 @@
384404
"result": []
385405
},
386406
{
387-
"expression": "reverse(``)",
407+
"expression": "reverse('')",
388408
"result": ""
389409
},
390410
{
391-
"expression": "reverse(`hello world`)",
411+
"expression": "reverse('hello world')",
392412
"result": "dlrow olleh"
393413
},
394414
{
395-
"expression": "starts_with(str, `S`)",
415+
"expression": "starts_with(str, 'S')",
396416
"result": true
397417
},
398418
{
399-
"expression": "starts_with(str, `St`)",
419+
"expression": "starts_with(str, 'St')",
400420
"result": true
401421
},
402422
{
403-
"expression": "starts_with(str, `Str`)",
423+
"expression": "starts_with(str, 'Str')",
404424
"result": true
405425
},
406426
{
407-
"expression": "starts_with(str, `String`)",
427+
"expression": "starts_with(str, 'String')",
408428
"result": false
409429
},
410430
{
@@ -432,7 +452,27 @@
432452
"result": 0
433453
},
434454
{
435-
"expression": "to_string(`foo`)",
455+
"expression": "to_array('foo')",
456+
"result": ["foo"]
457+
},
458+
{
459+
"expression": "to_array(`0`)",
460+
"result": [0]
461+
},
462+
{
463+
"expression": "to_array(objects)",
464+
"result": [{"foo": "bar", "bar": "baz"}]
465+
},
466+
{
467+
"expression": "to_array(`[1, 2, 3]`)",
468+
"result": [1, 2, 3]
469+
},
470+
{
471+
"expression": "to_array(false)",
472+
"result": [false]
473+
},
474+
{
475+
"expression": "to_string('foo')",
436476
"result": "foo"
437477
},
438478
{
@@ -444,19 +484,19 @@
444484
"result": "[0,1]"
445485
},
446486
{
447-
"expression": "to_number(`\"1.0\"`)",
487+
"expression": "to_number('1.0')",
448488
"result": 1.0
449489
},
450490
{
451-
"expression": "to_number(`\"1.1\"`)",
491+
"expression": "to_number('1.1')",
452492
"result": 1.1
453493
},
454494
{
455-
"expression": "to_number(`\"4\"`)",
495+
"expression": "to_number('4')",
456496
"result": 4
457497
},
458498
{
459-
"expression": "to_number(`\"notanumber\"`)",
499+
"expression": "to_number('notanumber')",
460500
"result": null
461501
},
462502
{
@@ -569,7 +609,7 @@
569609
},
570610
"cases": [
571611
{
572-
"description": "function projection on variadic function",
612+
"description": "sort by field expression",
573613
"expression": "sort_by(people, &age)",
574614
"result": [
575615
{"age": 10, "age_str": "10", "bool": true, "name": 3},
@@ -580,7 +620,7 @@
580620
]
581621
},
582622
{
583-
"description": "function projection on variadic function",
623+
"description": "sort by function expression",
584624
"expression": "sort_by(people, &to_number(age_str))",
585625
"result": [
586626
{"age": 10, "age_str": "10", "bool": true, "name": 3},
@@ -591,7 +631,7 @@
591631
]
592632
},
593633
{
594-
"description": "function projection on variadic function",
634+
"description": "function projection on sort_by function",
595635
"expression": "sort_by(people, &age)[].name",
596636
"result": [3, "a", "c", "b", "d"]
597637
},
@@ -615,6 +655,10 @@
615655
"expression": "sort_by(people, &age)[].extra",
616656
"result": ["foo", "bar"]
617657
},
658+
{
659+
"expression": "sort_by(`[]`, &age)",
660+
"result": []
661+
},
618662
{
619663
"expression": "max_by(people, &age)",
620664
"result": {"age": 50, "age_str": "50", "bool": false, "name": "d"}

0 commit comments

Comments
 (0)