diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-12 13:39:33 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-12 13:56:23 +0200 |
| commit | eaa3cbaa9c2b1564a4b0db013672245a1893314a (patch) | |
| tree | 616a3d0f3686793caffcef72f230f8ba79b8f3ca /tests/typ/code/array.typ | |
| parent | 8207c31aec6336b773fbf4661fdb87625c8b584e (diff) | |
Array and dictionary indexing
Diffstat (limited to 'tests/typ/code/array.typ')
| -rw-r--r-- | tests/typ/code/array.typ | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/typ/code/array.typ b/tests/typ/code/array.typ index fc8795c2..df37dd45 100644 --- a/tests/typ/code/array.typ +++ b/tests/typ/code/array.typ @@ -1,6 +1,9 @@ // Test arrays. +// Ref: false --- +// Ref: true + // Empty. {()} @@ -19,6 +22,39 @@ ,)} --- +// Test lvalue and rvalue access. +{ + let array = (1, 2) + array(1) += 5 + array(0) + test(array, (1, 8)) +} + +--- +// Test rvalue out of bounds. +{ + let array = (1, 2, 3) + // Error: 3-11 array index out of bounds (index: 5, len: 3) + array(5) +} + +--- +// Test lvalue out of bounds. +{ + let array = (1, 2, 3) + // Error: 3-12 array index out of bounds (index: -1, len: 3) + array(-1) = 5 +} + +--- +// Test non-collection indexing. + +{ + let x = 10pt + // Error: 3-4 expected collection, found length + x() = 1 +} + +--- // Error: 3 expected closing paren {(} |
