summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2023-08-04 00:04:57 -0500
committerEmanuele Torre <torreemanuele6@gmail.com>2023-08-27 12:32:12 +0200
commit0e067ef93605493060392f0999be27694146fca4 (patch)
tree177d7d71e2e212a95b28a9596dfb01df8d07a4e6 /tests
parentab47880b4c6a6cda55a4c6b93f7990baef990e1e (diff)
Improve handling of non-integer numeric indices (fix #2815)jq-1.7rc2
Diffstat (limited to 'tests')
-rw-r--r--tests/jq.test58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test
index e35722fd..9d0b5928 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -2024,3 +2024,61 @@ walk(1)
walk(select(IN({}, []) | not))
{"a":1,"b":[]}
{"a":1}
+
+# #2815
+[range(10)] | .[1.2:3.5]
+null
+[1,2,3]
+
+[range(10)] | .[1.5:3.5]
+null
+[1,2,3]
+
+[range(10)] | .[1.7:3.5]
+null
+[1,2,3]
+
+[range(10)] | .[1.7:4294967295]
+null
+[1,2,3,4,5,6,7,8,9]
+
+[range(10)] | .[1.7:-4294967296]
+null
+[]
+
+[[range(10)] | .[1.1,1.5,1.7]]
+null
+[1,1,1]
+
+[range(5)] | .[1.1] = 5
+null
+[0,5,2,3,4]
+
+[range(3)] | .[nan:1]
+null
+[0]
+
+[range(3)] | .[1:nan]
+null
+[1,2]
+
+[range(3)] | .[nan]
+null
+null
+
+try ([range(3)] | .[nan] = 9) catch .
+null
+"Cannot set array element at NaN index"
+
+try ("foobar" | .[1.5:3.5] = "xyz") catch .
+null
+"Cannot update string slices"
+
+try ([range(10)] | .[1.5:3.5] = ["xyz"]) catch .
+null
+[0,"xyz",4,5,6,7,8,9]
+
+try ("foobar" | .[1.5]) catch .
+null
+"Cannot index string with number"
+