From cfa1ef52a2939e3303069de65f6f54bc32bc2e52 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Thu, 17 Mar 2005 23:16:31 +0000 Subject: [PATCH] (filter-map): More tests. --- test-suite/tests/srfi-1.test | 59 ++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/test-suite/tests/srfi-1.test b/test-suite/tests/srfi-1.test index 93d7329fe..b8713b12e 100644 --- a/test-suite/tests/srfi-1.test +++ b/test-suite/tests/srfi-1.test @@ -717,6 +717,12 @@ (with-test-prefix "filter-map" (with-test-prefix "one list" + (pass-if-exception "'x" exception:wrong-type-arg + (filter-map noop 'x)) + + (pass-if-exception "'(1 . x)" exception:wrong-type-arg + (filter-map noop '(1 . x))) + (pass-if "(1)" (equal? '(1) (filter-map noop '(1)))) @@ -745,14 +751,63 @@ (equal? '(1 2) (filter-map noop '(1 2 #f))))) (with-test-prefix "two lists" + (pass-if-exception "'x '(1 2 3)" exception:wrong-type-arg + (filter-map noop 'x '(1 2 3))) + + (pass-if-exception "'(1 2 3) 'x" exception:wrong-type-arg + (filter-map noop '(1 2 3) 'x)) + + (pass-if-exception "'(1 . x) '(1 2 3)" exception:wrong-type-arg + (filter-map noop '(1 . x) '(1 2 3))) + + (pass-if-exception "'(1 2 3) '(1 . x)" exception:wrong-type-arg + (filter-map noop '(1 2 3) '(1 . x))) + (pass-if "(1 2 3) (4 5 6)" - (equal? '(1 2 3) (filter-map noop '(1 2 3) '(4 5 6)))) + (equal? '(5 7 9) (filter-map + '(1 2 3) '(4 5 6)))) (pass-if "(#f 2 3) (4 5)" (equal? '(2) (filter-map noop '(#f 2 3) '(4 5)))) (pass-if "(4 #f) (1 2 3)" - (equal? '(4) (filter-map noop '(4 #f) '(1 2 3)))))) + (equal? '(4) (filter-map noop '(4 #f) '(1 2 3)))) + + (pass-if "() (1 2 3)" + (equal? '() (filter-map noop '() '(1 2 3)))) + + (pass-if "(1 2 3) ()" + (equal? '() (filter-map noop '(1 2 3) '())))) + + (with-test-prefix "three lists" + (pass-if-exception "'x '(1 2 3) '(1 2 3)" exception:wrong-type-arg + (filter-map noop 'x '(1 2 3) '(1 2 3))) + + (pass-if-exception "'(1 2 3) 'x '(1 2 3)" exception:wrong-type-arg + (filter-map noop '(1 2 3) 'x '(1 2 3))) + + (pass-if-exception "'(1 2 3) '(1 2 3) 'x" exception:wrong-type-arg + (filter-map noop '(1 2 3) '(1 2 3) 'x)) + + (pass-if-exception "'(1 . x) '(1 2 3) '(1 2 3)" exception:wrong-type-arg + (filter-map noop '(1 . x) '(1 2 3) '(1 2 3))) + + (pass-if-exception "'(1 2 3) '(1 . x) '(1 2 3)" exception:wrong-type-arg + (filter-map noop '(1 2 3) '(1 . x) '(1 2 3))) + + (pass-if-exception "'(1 2 3) '(1 2 3) '(1 . x)" exception:wrong-type-arg + (filter-map noop '(1 2 3) '(1 2 3) '(1 . x))) + + (pass-if "(1 2 3) (4 5 6) (7 8 9)" + (equal? '(12 15 18) (filter-map + '(1 2 3) '(4 5 6) '(7 8 9)))) + + (pass-if "(#f 2 3) (4 5) (7 8 9)" + (equal? '(2) (filter-map noop '(#f 2 3) '(4 5) '(7 8 9)))) + + (pass-if "(#f 2 3) (7 8 9) (4 5)" + (equal? '(2) (filter-map noop '(#f 2 3) '(7 8 9) '(4 5)))) + + (pass-if "(4 #f) (1 2 3) (7 8 9)" + (equal? '(4) (filter-map noop '(4 #f) '(1 2 3) '(7 8 9)))))) ;; ;; find