1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 22:31:12 +02:00

(filter-map): More tests.

This commit is contained in:
Kevin Ryde 2005-03-17 23:16:31 +00:00
parent c16359466b
commit cfa1ef52a2

View file

@ -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