diff options
| author | SekoiaTree <51149447+SekoiaTree@users.noreply.github.com> | 2023-04-25 11:18:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 11:18:27 +0200 |
| commit | efad1e71fa699e0d2413d3a6a3ce5a4163e38112 (patch) | |
| tree | 64dd37c540989e71408ee005abdccdb523d76618 /tests | |
| parent | 12129f01707a3389ef90a4c78a872e1c7897a752 (diff) | |
Add sum and product to arrays (#966)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/compiler/array.png | bin | 9459 -> 8385 bytes | |||
| -rw-r--r-- | tests/typ/compiler/array.typ | 21 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/ref/compiler/array.png b/tests/ref/compiler/array.png Binary files differindex a7c52f1a..a96dfe64 100644 --- a/tests/ref/compiler/array.png +++ b/tests/ref/compiler/array.png diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ index c9e85ed7..c52160b0 100644 --- a/tests/typ/compiler/array.typ +++ b/tests/typ/compiler/array.typ @@ -167,6 +167,27 @@ #(1, 2, 3).fold(0, () => none) --- +// Test the `sum` method. +#test(().sum(default: 0), 0) +#test(().sum(default: []), []) +#test((1, 2, 3).sum(), 6) + +--- +// Error: 2-10 cannot calculate sum of empty array with no default +#().sum() + +--- +// Test the `product` method. +#test(().product(default: 0), 0) +#test(().product(default: []), []) +#test(([ab], 3).product(), [ab]*3) +#test((1, 2, 3).product(), 6) + +--- +// Error: 2-14 cannot calculate product of empty array with no default +#().product() + +--- // Test the `rev` method. #test(range(3).rev(), (2, 1, 0)) |
