(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))))
(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