lib/lisp/tests/boot-tests.nydp in nydp-0.0.12 vs lib/lisp/tests/boot-tests.nydp in nydp-0.1.0

- old
+ new

@@ -136,9 +136,38 @@ (suite "mapx" ("provides a convenient simplification for 'map" (mapx '(1 2 3 4) n (* n 2)) (2 4 6 8)))) + (suite "reduce" + ("it applies a function cumulatively over a list" + (reduce + '(1 2 3)) + 6)) + + (suite "detect" + ("returns first matching item in a list" + (detect (fn (x) (eq? (len x) 2)) + (list "foo" "bar" "xx" "pp")) + "xx") + + ("returns nil when nothing matches" + (detect (fn (x) (eq? (len x) 20)) + (list "foo" "bar" "xx" "pp")) + nil) + + ;; kind of pointless + ("returns nil if nil is the matching item" + (detect no (list "foo" "bar" nil "pp")) + nil) + + ("returns item if it's an atom and matches" + (detect (fn (x) (eq? (len x) 2)) "zz") + "zz") + + ("returns nil if it's an atom and doesn't match" + (detect (fn (x) (eq? (len x) 20)) + "zz") + nil)) (suite "pre-compile" (suite "bang-syntax" ("expansion" (pre-compile '(!eq? a b))