lib/lisp/tests/boot-tests.nydp in nydp-0.0.4 vs lib/lisp/tests/boot-tests.nydp in nydp-0.0.5
- old
+ new
@@ -20,11 +20,42 @@
(make-plus +seven 7)
(make-plus +eleven 11)
(register-test
'(suite "Boot Tests"
+ (suite "list management"
+ ("'pair breaks a list into pairs"
+ (pairs '(1 a 2 b 3 c))
+ ((1 a) (2 b) (3 c)))
+ ("'flatten returns a flat list of things"
+ (flatten '((poo (x) (* x x)) (1 2 3)))
+ (poo x * x x 1 2 3)))
+
+ (suite "map"
+ ("maps a function over a list of numbers"
+ (map (fn (x) (* x x)) '(1 2 3))
+ (1 4 9)))
+
(suite "quasiquote"
+ ("same as quote for standalone item"
+ `a
+ a)
+ ("same as quote for standalone list"
+ `(a b c)
+ (a b c))
+ ("substitutes single variables"
+ (let b 10 `(a ,b c))
+ (a 10 c))
+ ("substitutes a list"
+ (let b '(1 2 3) `(a ,@b c))
+ (a 1 2 3 c))
+ ("substitutes a list at the end of a given list"
+ (let b '(1 2 3) `(a ,b ,@b))
+ (a (1 2 3) 1 2 3))
+ ("more complicated substitution example"
+ (with (d '(1 2 3) g '(x y z)) `(a (b c ,d (e f ,@g))))
+ (a (b c (1 2 3) (e f x y z))))
("peeks inside nested quotes"
`(a b '(c ,(+ 1 2)))
(a b '(c 3)))
("handles nested unquote-splicing"
``(a ,,@(list '+ 1 2) b)