From ffad8516af0b91121dc0761c8026e0a12939a7d4 Mon Sep 17 00:00:00 2001 From: Michael Lohr Date: Wed, 3 May 2023 12:34:35 +0200 Subject: Implement default values for at() (#995) --- tests/typ/compiler/array.typ | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/typ/compiler/array.typ') 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,17 +47,22 @@ --- // 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 @@ -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) --- -- cgit v1.2.3