Skip to content

Commit 88a0cb3

Browse files
authored
Merge pull request #11 from jmespath/more-cases
Add additional test cases and fixes
2 parents 0fd0bd1 + 7522d2d commit 88a0cb3

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

tests/benchmarks.json

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,36 @@
3232
}
3333
}
3434
}
35+
},
36+
"b": true,
37+
"c": {
38+
"d": true
3539
}
3640
},
3741
"cases": [
3842
{
3943
"comment": "simple field",
40-
"expression": "a",
44+
"expression": "b",
4145
"bench": "full"
4246
},
4347
{
4448
"comment": "simple subexpression",
45-
"expression": "a.b",
49+
"expression": "c.d",
4650
"bench": "full"
4751
},
4852
{
49-
"comment": "deep field selection",
53+
"comment": "deep field selection no match",
5054
"expression": "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s",
5155
"bench": "full"
5256
},
57+
{
58+
"comment": "deep field selection",
59+
"expression": "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p",
60+
"bench": "full"
61+
},
5362
{
5463
"comment": "simple or",
55-
"expression": "not_there || a",
64+
"expression": "not_there || b",
5665
"bench": "full"
5766
}
5867
]
@@ -76,7 +85,12 @@
7685
},
7786
{
7887
"comment": "lots of summing",
79-
"expression": "sum(z, y, x, w, v, u, t, s, r, q, p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, a)",
88+
"expression": "sum([z, y, x, w, v, u, t, s, r, q, p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, a])",
89+
"bench": "full"
90+
},
91+
{
92+
"comment": "lots of function application",
93+
"expression": "sum([z, sum([y, sum([x, sum([w, sum([v, sum([u, sum([t, sum([s, sum([r, sum([q, sum([p, sum([o, sum([n, sum([m, sum([l, sum([k, sum([j, sum([i, sum([h, sum([g, sum([f, sum([e, sum([d, sum([c, sum([b, a])])])])])])])])])])])])])])])])])])])])])])])])])",
8094
"bench": "full"
8195
},
8296
{
@@ -116,7 +130,7 @@
116130
},
117131
{
118132
"comment": "filter projection",
119-
"expression": "foo[bar > baz][qux > baz]",
133+
"expression": "foo[?bar > baz][?qux > baz]",
120134
"bench": "parse"
121135
}
122136
]

tests/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/functions.json

Lines changed: 4 additions & 0 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

tests/syntax.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@
9595
{
9696
"expression": "!",
9797
"error": "syntax"
98+
},
99+
{
100+
"expression": "@=",
101+
"error": "syntax"
102+
},
103+
{
104+
"expression": "@``",
105+
"error": "syntax"
98106
}
99107
]
100108
},

0 commit comments

Comments
 (0)