summaryrefslogtreecommitdiff
path: root/tests/typ/code
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/code
parentcd62792c0aefffe8b0a5c7fc76e95dfa7b86a181 (diff)
Negative array indexing
Diffstat (limited to 'tests/typ/code')
-rw-r--r--tests/typ/code/array.typ24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/typ/code/array.typ b/tests/typ/code/array.typ
index df37dd45..cd163175 100644
--- a/tests/typ/code/array.typ
+++ b/tests/typ/code/array.typ
@@ -31,21 +31,33 @@
---
// Test rvalue out of bounds.
+// Error: 2-14 array index out of bounds (index: 5, len: 3)
+{(1, 2, 3)(5)}
+
+---
+// Test lvalue out of bounds.
{
let array = (1, 2, 3)
- // Error: 3-11 array index out of bounds (index: 5, len: 3)
- array(5)
+ // Error: 3-11 array index out of bounds (index: 3, len: 3)
+ array(3) = 5
}
---
-// Test lvalue out of bounds.
+// Test negative indices.
{
- let array = (1, 2, 3)
- // Error: 3-12 array index out of bounds (index: -1, len: 3)
- array(-1) = 5
+ let array = (1, 2, 3, 4)
+ test(array(0), 1)
+ test(array(-1), 4)
+ test(array(-2), 3)
+ test(array(-3), 2)
+ test(array(-4), 1)
}
---
+// Error: 2-15 array index out of bounds (index: -4, len: 3)
+{(1, 2, 3)(-4)}
+
+---
// Test non-collection indexing.
{