about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorArun Isaac2025-12-31 21:11:15 +0000
committerArun Isaac2025-12-31 21:11:15 +0000
commitcd57f867069c4e86a9c02682ddec27baa21152ac (patch)
treef52737022ba1b0da14b6f0da0c974cb94bc0ad5b /tests
parent4f757fc0a4d4af067e0d22ad4020c1b18cc3fd24 (diff)
downloadccwl-cd57f867069c4e86a9c02682ddec27baa21152ac.tar.gz
ccwl-cd57f867069c4e86a9c02682ddec27baa21152ac.tar.lz
ccwl-cd57f867069c4e86a9c02682ddec27baa21152ac.zip
utils: Require arity for mapn. HEAD main
With an empty list, mapn cannot know the number of values proc would
return. mapn therefore needs to know the arity of proc. To provide for
existing callers of mapn, we add a map2 function variant. Finally, we
add a test case testing mapn on an empty list.
Diffstat (limited to 'tests')
-rw-r--r--tests/utils.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index 50c3396..d786d02 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -1,5 +1,5 @@
 ;;; ccwl --- Concise Common Workflow Language
-;;; Copyright © 2021, 2022, 2023 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2021, 2022, 2023, 2025 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ccwl.
 ;;;
@@ -194,7 +194,17 @@
   (let ((squares cubes (mapn (lambda (n)
                                (values (expt n 2)
                                        (expt n 3)))
-                             (iota 5))))
+                             (iota 5)
+                             2)))
+    (list squares cubes)))
+
+(test-equal "mapn on an empty list"
+  '(() ())
+  (let ((squares cubes (mapn (lambda (n)
+                               (values (expt n 2)
+                                       (expt n 3)))
+                             '()
+                             2)))
     (list squares cubes)))
 
 (test-equal "foldn"