From 336c3deb8a9f4d30d1cf27fb98aecf61ef20f99d Mon Sep 17 00:00:00 2001 From: pkoppstein Date: Sat, 15 Jul 2023 21:50:19 -0400 Subject: [PATCH] Test negative indices in path expressions --- tests/jq.test | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/jq.test b/tests/jq.test index ee32be5da8..55630a5a43 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 #