summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/array.typ
diff options
context:
space:
mode:
authorMichael Lohr <michael@lohr.dev>2023-05-03 12:34:35 +0200
committerGitHub <noreply@github.com>2023-05-03 12:34:35 +0200
commitffad8516af0b91121dc0761c8026e0a12939a7d4 (patch)
treeada5c6b5510b5f509997ccf5308a9cafc8618990 /tests/typ/compiler/array.typ
parentca8462642a96ec282afeb0774b6d5daf546ac236 (diff)
Implement default values for at() (#995)
Diffstat (limited to 'tests/typ/compiler/array.typ')
-rw-r--r--tests/typ/compiler/array.typ11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ
index 5d7e8b63..ef6e4b6b 100644
--- a/tests/typ/compiler/array.typ
+++ b/tests/typ/compiler/array.typ
@@ -47,18 +47,23 @@
---
// Test rvalue out of bounds.
-// Error: 2-17 array index out of bounds (index: 5, len: 3)
+// Error: 2-17 array index out of bounds (index: 5, len: 3) and no default value was specified
#(1, 2, 3).at(5)
---
// Test lvalue out of bounds.
#{
let array = (1, 2, 3)
- // Error: 3-14 array index out of bounds (index: 3, len: 3)
+ // Error: 3-14 array index out of bounds (index: 3, len: 3) and no default value was specified
array.at(3) = 5
}
---
+// Test default value.
+#test((1, 2, 3).at(2, default: 5), 3)
+#test((1, 2, 3).at(3, default: 5), 5)
+
+---
// Test bad lvalue.
// Error: 2:3-2:14 cannot mutate a temporary value
#let array = (1, 2, 3)
@@ -243,7 +248,7 @@
#([Hi], [There]).sorted()
---
-// Error: 2-18 array index out of bounds (index: -4, len: 3)
+// Error: 2-18 array index out of bounds (index: -4, len: 3) and no default value was specified
#(1, 2, 3).at(-4)
---