summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/compiler/array.pngbin9459 -> 8385 bytes
-rw-r--r--tests/typ/compiler/array.typ21
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/ref/compiler/array.png b/tests/ref/compiler/array.png
index a7c52f1a..a96dfe64 100644
--- a/tests/ref/compiler/array.png
+++ b/tests/ref/compiler/array.png
Binary files differ
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))