Skip to content

Commit 336c3de

Browse files
pkoppsteinnicowilliams
authored andcommitted
Test negative indices in path expressions
1 parent 086a156 commit 336c3de

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/jq.test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,28 @@ del(.[1], .[-6], .[2], .[-3:9])
10021002
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
10031003
[0, 3, 5, 6, 9]
10041004

1005+
# negative index
1006+
setpath([-1]; 1)
1007+
[0]
1008+
[1]
1009+
1010+
pick(.a.b.c)
1011+
null
1012+
{"a":{"b":{"c":null}}}
1013+
1014+
pick(first)
1015+
[1,2]
1016+
[1]
1017+
1018+
pick(first|first)
1019+
[[10,20],30]
1020+
[[10]]
1021+
1022+
# negative indices in path expressions (since last/1 is .[-1])
1023+
pick(last)
1024+
[[10,20],30]
1025+
[null,30]
1026+
10051027
#
10061028
# Assignment
10071029
#

0 commit comments

Comments
 (0)