summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkoppstein <pkoppstein@gmail.com>2023-07-15 21:50:19 -0400
committerNico Williams <nico@cryptonector.com>2023-07-28 12:34:26 -0500
commit336c3deb8a9f4d30d1cf27fb98aecf61ef20f99d (patch)
tree504e45cf7e983db3df6f397e7633d3bdfc049e93
parent086a156ec389de167edc72e8bd1752984b117349 (diff)
Test negative indices in path expressions
-rw-r--r--tests/jq.test22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test
index ee32be5d..55630a5a 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -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
#