Skip to content

Commit 509e460

Browse files
authored
Add tests of selector that follows another selector. Resolves #96 (#102)
1 parent b1e176a commit 509e460

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

tests/filter.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,34 @@
19101910
"result": [],
19111911
"result_paths": []
19121912
},
1913+
{
1914+
"name": "followed by name selector",
1915+
"selector": "$[[email protected]==1].b.x",
1916+
"document": [
1917+
{
1918+
"a": 1,
1919+
"b": { "x": 2 }
1920+
}
1921+
],
1922+
"result": [ 2 ],
1923+
"result_paths": [
1924+
"$[0]['b']['x']"
1925+
]
1926+
},
1927+
{
1928+
"name": "followed by child segment that selects multiple elements",
1929+
"selector": "$[[email protected]=='_']['x','y']",
1930+
"document": [
1931+
{
1932+
"x": 1, "y": null, "z": "_"
1933+
}
1934+
],
1935+
"result": [ 1, null ],
1936+
"result_paths": [
1937+
"$[0]['x']",
1938+
"$[0]['y']"
1939+
]
1940+
},
19131941
{
19141942
"name": "relative non-singular query, index, equal",
19151943
"selector": "$[?(@[0, 0]==42)]",
@@ -3381,4 +3409,4 @@
33813409
]
33823410
}
33833411
]
3384-
}
3412+
}

tests/slice_selector.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,55 @@
523523
"slice"
524524
]
525525
},
526+
{
527+
"name": "in serial, on nested array",
528+
"selector": "$[1:3][1:2]",
529+
"document": [
530+
[
531+
"a",
532+
"b",
533+
"c"
534+
],
535+
[
536+
"d",
537+
"e",
538+
"f"
539+
],
540+
[
541+
"g",
542+
"h",
543+
"i"
544+
]
545+
],
546+
"result": [
547+
"e",
548+
"h"
549+
],
550+
"result_paths": [
551+
"$[1][1]",
552+
"$[2][1]"
553+
],
554+
"tags": [
555+
"slice"
556+
]
557+
},
558+
{
559+
"name": "in serial, on flat array",
560+
"selector": "$[1:3][::]",
561+
"document": [
562+
0,
563+
1,
564+
2,
565+
3,
566+
4,
567+
5
568+
],
569+
"result": [],
570+
"result_paths": [],
571+
"tags": [
572+
"slice"
573+
]
574+
},
526575
{
527576
"name": "too many colons",
528577
"selector": "$[1:2:3:4]",
@@ -1196,4 +1245,4 @@
11961245
]
11971246
}
11981247
]
1199-
}
1248+
}

0 commit comments

Comments
 (0)