lib/lisp/tests/include-examples.nydp in nydp-0.1.10 vs lib/lisp/tests/include-examples.nydp in nydp-0.1.11
- old
+ new
@@ -16,5 +16,28 @@
42)
("nil for 42 in list not containing 42"
(include? 42 '(1 2 nil 3 (a b c) 4))
nil))
+
+(examples-for seen?
+ ("returns a function which returns t for every previously-seen argument, nil otherwise"
+ (map (seen?) '(a b c d a a e f b b g h c c i j d d k l a b c d))
+ (nil nil nil nil t t nil nil t t nil nil t t nil nil t t nil nil t t t t))
+
+ ("each 'seen? is independent"
+ (with (s1 (seen?) s2 (seen?) syms '(a b c a d b e c f))
+ (list (map s1 syms) (map s2 syms)))
+ ((nil nil nil t nil t nil t nil)
+ (nil nil nil t nil t nil t nil))))
+
+(examples-for uniqify
+ ("returns a list with duplicates removed"
+ (uniqify '(a b c d a a e f b b g h c c i j d d k l a b c d))
+ (a b c d e f g h i j k l))
+
+ ("removes duplicate dates"
+ (let d (date 2004 3 12)
+ (joinstr " "
+ (uniqify (map λx(+ d x)
+ '(0 2 3 3 4 3 5 0 5) ))))
+ "2004-03-12 2004-03-14 2004-03-15 2004-03-16 2004-03-17"))