summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-11-18 19:55:47 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-11-18 19:55:47 +0100
commitb1605ef9a7f21e7caf3d033b5ac7df0b8da5c3fe (patch)
tree426963e177ae2aade02a6d97ba70a893607de74f /tests
parent3779df17f2726c2ad4c6904016f2b27c5049ed0d (diff)
downloadmew-b1605ef9a7f21e7caf3d033b5ac7df0b8da5c3fe.tar.gz
mew-b1605ef9a7f21e7caf3d033b5ac7df0b8da5c3fe.tar.xz
mew-b1605ef9a7f21e7caf3d033b5ac7df0b8da5c3fe.zip
add xfold, xfold-right, xreduce, xreduce-right, xscan, xscan-right
Make scan, scan-right work with multiple lists.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.mew30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/test.mew b/tests/test.mew
index 328e282..e638377 100644
--- a/tests/test.mew
+++ b/tests/test.mew
@@ -532,11 +532,37 @@
 
 (test-group "scan"
   (test '(0 -4 -9 -15) (scan (flip -) 0 '(4 5 6)))
-  (test '(42) (scan * 42 '())))
+  (test '(42) (scan * 42 '()))
+  (test '(0 6 14 24 36) (scan + 0 '(1 2 3 4) '(5 6 7 8)))
+  (test '(0 -4 0 -4 0) (scan - 0 '(1 2 3 4) '(5 6 7 8))))
+
+(test-group "xscan"
+  (test '(0 6 14 24 36) (xscan + 0 '(1 2 3 4) '(5 6 7 8)))
+  (test '(0 -6 -14 -24 -36) (xscan - 0 '(1 2 3 4) '(5 6 7 8))))
 
 (test-group "scan-right"
   (test '(5 -1 6 0)    (scan-right - 0 '(4 5 6)))
-  (test '(42) (scan-right * 42 '())))
+  (test '(42) (scan-right * 42 '()))
+  (test '(36 30 22 12 0) (scan-right + 0 '(1 2 3 4) '(5 6 7 8))))
+
+(test-group "xscan-right"
+  (test '(36 30 22 12 0) (xscan-right + 0 '(1 2 3 4) '(5 6 7 8))))
+
+(test-group "xfold"
+  (test -10 (xfold - 0 '(1 2 3 4)))
+  (test '((((() 1 5) 2 6) 3 7) 4 8) (xfold list '() '(1 2 3 4) '(5 6 7 8))))
+
+(test-group "xfold-right"
+  (test '((((() 4 8) 3 7) 2 6) 1 5) (xfold-right list '() '(1 2 3 4) '(5 6 7 8)))
+  (test -10 (xfold-right - 0 '(1 2 3 4))))
+
+(test-group "xreduce"
+  (test -8 (xreduce - 0 '(1 2 3 4)))
+  (test #f (xreduce - #f '())))
+
+(test-group "xreduce-right"
+  (test -2 (xreduce-right - 0 '(1 2 3 4)))
+  (test #f (xreduce-right - #f '())))
 
 (test-group "imp"
   (test #t (imp #t #t))