summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-03-01 20:41:54 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-03-01 20:41:54 -0800
commit1134089866fde0478fe869aa6fa13e105325ddcd (patch)
tree714467630869f07c53403f84e1e791c5d229eb59 /tests
parentd102e01cc47fedbb008ea5ea3757ad4415e1e4eb (diff)
downloadtxr-1134089866fde0478fe869aa6fa13e105325ddcd.tar.gz
txr-1134089866fde0478fe869aa6fa13e105325ddcd.tar.bz2
txr-1134089866fde0478fe869aa6fa13e105325ddcd.zip
zip: make more generic.
* lib.c (do_pa_12_1_v, pa_12_1_v): Static functions removed. (transposev, transpose): Functions removed. * lib.c (transposev, transpose): Declarations removed. * eval.c (join_f): New global variable. (zip_fun, zipv, transpose): New static functions. (eval_init): gc-protect join_f, and initialize it. Registration of zip intrinsic goes to zipv rather than transposev. sys:fmt-join and join registered with help of global join_f rather than local. * tests/012/seq.tl: New zip test cases.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/seq.tl66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl
index 144c6971..6ea572fe 100644
--- a/tests/012/seq.tl
+++ b/tests/012/seq.tl
@@ -756,3 +756,69 @@
(lambda (z)
(+ x y z))))))
(test [mref cf 1 2 3] 6))
+
+(test
+ (zip) nil)
+
+(mtest
+ (zip '()) nil
+ (zip #()) #()
+ (zip "") ""
+ (zip #b'') #b'')
+
+(mtest
+ (zip '(a)) ((a))
+ (zip '(a b)) ((a) (b))
+ (zip '(a b c)) ((a) (b) (c)))
+
+(mtest
+ (zip #(a)) #(#(a))
+ (zip #(a b)) #(#(a) #(b))
+ (zip #(a b c)) #(#(a) #(b) #(c)))
+
+(mtest
+ (zip "a") ("a")
+ (zip "ab") ("a" "b")
+ (zip "abc") ("a" "b" "c"))
+
+(mtest
+ (zip #b'aa') (#b'aa')
+ (zip #b'aabb') (#b'aa' #b'bb')
+ (zip #b'aabbcc') (#b'aa' #b'bb' #b'cc'))
+
+(mtest
+ (zip '(a) '(b)) ((a b))
+ (zip '(a c) '(b d)) ((a b) (c d))
+ (zip '(a c e) '(b d f)) ((a b) (c d) (e f))
+ (zip '(a d) '(b e) '(c f)) ((a b c) (d e f)))
+
+(mtest
+ (zip #(a) #(b)) #(#(a b))
+ (zip #(a c) #(b d)) #(#(a b) #(c d))
+ (zip #(a c e) #(b d f)) #(#(a b) #(c d) #(e f))
+ (zip #(a d) #(b e) #(c f)) #(#(a b c) #(d e f)))
+
+(mtest
+ (zip #(a) #(b)) #(#(a b))
+ (zip #(a c) #(b d)) #(#(a b) #(c d))
+ (zip #(a c e) #(b d f)) #(#(a b) #(c d) #(e f))
+ (zip #(a d) #(b e) #(c f)) #(#(a b c) #(d e f)))
+
+(mtest
+ (zip "a" "b") ("ab")
+ (zip "ac" "bd") ("ab" "cd")
+ (zip "ace" "bdf") ("ab" "cd" "ef")
+ (zip "ad" "bef" "cf") ("abc" "def"))
+
+(mtest
+ (zip #b'aa' #b'bb') (#b'aabb')
+ (zip #b'aacc' #b'bbdd') (#b'aabb' #b'ccdd')
+ (zip #b'aaccee' #b'bbddff') (#b'aabb' #b'ccdd' #b'eeff')
+ (zip #b'aaddee' #b'bbeeff' #b'ccff') (#b'aabbcc' #b'ddeeff'))
+
+(test
+ (zip "ab" "ijklm" "xy") ("aix" "bjy"))
+
+(test
+ (zip "ab" '(#\i #\j) #("x" "y")) ("aix" "bjy"))
+