summaryrefslogtreecommitdiffstats
path: root/tests/010
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-02 20:50:34 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-03-02 20:50:34 -0800
commit9175dc378d5b2a6da0810d17407c3decfa91206a (patch)
treea9eecf7fe01536a776bf513a4cf1a5b2297d38fd /tests/010
parent8a664a3d518d8955155169e8f9637343f2208013 (diff)
downloadtxr-9175dc378d5b2a6da0810d17407c3decfa91206a.tar.gz
txr-9175dc378d5b2a6da0810d17407c3decfa91206a.tar.bz2
txr-9175dc378d5b2a6da0810d17407c3decfa91206a.zip
hash: add tests for group-by, group-reduce.
* tests/010/hash.tl: New tests.
Diffstat (limited to 'tests/010')
-rw-r--r--tests/010/hash.tl16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/010/hash.tl b/tests/010/hash.tl
index b8c386e2..bb006612 100644
--- a/tests/010/hash.tl
+++ b/tests/010/hash.tl
@@ -4,3 +4,19 @@
(uni #H(() ("a") ("b")) #H(() ("b") ("c"))) (("a") ("b") ("c"))
(diff #H(() ("a") ("b")) #H(() ("b") ("c"))) (("a"))
(isec #H(() ("a") ("b")) #H(() ("b") ("c"))) (("b")))
+
+(mtest
+ [group-by identity '(1 1 2 2 3 3 3)] #H(() (1 (1 1)) (2 (2 2)) (3 (3 3 3)))
+ (group-by (op mod @1 3) (range 0 10)) #H(() (0 (0 3 6 9))
+ (1 (1 4 7 10))
+ (2 (2 5 8))))
+
+
+(mtest
+ [group-reduce (hash) identity (do inc @1)
+ "fourscoreandsevenyearsago" 0] #H(() (#\a 3) (#\c 1) (#\d 1)
+ (#\e 4) (#\f 1) (#\g 1)
+ (#\n 2) (#\o 3) (#\r 3)
+ (#\s 3) (#\u 1) (#\v 1)
+ (#\y 1))
+ [group-reduce (hash) evenp + (range 1 10) 0] #H(() (t 30) (nil 25)))