summaryrefslogtreecommitdiff
path: root/tests/typ/utility
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-11 16:30:34 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-11 16:30:34 +0200
commit1101a8370f33bf31e4d9840ab8d932b8449267e8 (patch)
tree7e6dd4291495a248bad4d963007561cb9e70f33d /tests/typ/utility
parentcd62792c0aefffe8b0a5c7fc76e95dfa7b86a181 (diff)
Negative array indexing
Diffstat (limited to 'tests/typ/utility')
-rw-r--r--tests/typ/utility/collection.typ8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/typ/utility/collection.typ b/tests/typ/utility/collection.typ
index 924200cb..3414f0a9 100644
--- a/tests/typ/utility/collection.typ
+++ b/tests/typ/utility/collection.typ
@@ -38,12 +38,20 @@
#test((1, 2, 3, 4).slice(2), (3, 4))
#test(range(10).slice(2, 6), (2, 3, 4, 5))
#test(range(10).slice(4, count: 3), (4, 5, 6))
+#test((1, 2, 3).slice(2, -2), ())
+#test((1, 2, 3).slice(-2, 2), (2,))
+#test((1, 2, 3).slice(-3, 2), (1, 2))
+#test("ABCD".split("").slice(1, -1).join("-"), "A-B-C-D")
---
// Error: 3-31 array index out of bounds (index: 12, len: 10)
{ range(10).slice(9, count: 3) }
---
+// Error: 3-25 array index out of bounds (index: -4, len: 3)
+{ (1, 2, 3).slice(0, -4) }
+
+---
// Error: 2:17-2:19 missing argument: index
#let numbers = ()
{ numbers.insert() }