Skip to content

Commit

Permalink
Test negative indices in path expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoppstein authored and nicowilliams committed Jul 27, 2023
1 parent a6fe347 commit eb04831
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/jq.test
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,28 @@ del(.[1], .[-6], .[2], .[-3:9])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 3, 5, 6, 9]

# negative index
setpath([-1]; 1)
[0]
[1]

pick(.a.b.c)
null
{"a":{"b":{"c":null}}}

pick(first)
[1,2]
[1]

pick(first|first)
[[10,20],30]
[[10]]

# negative indices in path expressions (since last/1 is .[-1])
pick(last)
[[10,20],30]
[null,30]

#
# Assignment
#
Expand Down

0 comments on commit eb04831

Please sign in to comment.