lib/lisp/tests/boot-tests.nydp in nydp-0.0.8 vs lib/lisp/tests/boot-tests.nydp in nydp-0.0.9

- old
+ new

@@ -106,10 +106,15 @@ ("maps a string join function over a list of strings" (test-foo "x" "y") ("a0 w0 x w0 y" "a0 w1 x w1 y" "a0 w2 x w2 y" "a0 w3 x w3 y")) + (suite "mapx" + ("provides a convenient simplification for 'map" + (mapx '(1 2 3 4) n (* n 2)) + (2 4 6 8))) + (suite "pre-compile" (suite "bang-syntax" ("expansion" (pre-compile '(!eq? a b)) ((fn args (no (apply eq? args))) a b)) @@ -124,10 +129,33 @@ ("bang-syntax for 'caris" (!caris 'foo '(zozo foo bar)) t)) + (suite "ampersand-syntax" + ("defines a hash-lookup function" + (pre-compile '&first) + (fn (obj) (hash-get obj (quote first)))) + + ("defines a hash-lookup function with a dot-syntax arg" + (pre-compile '&teacher.address.city) + (fn (obj) (hash-get (hash-get (hash-get obj (quote teacher)) (quote address)) (quote city))) )) + + (suite "colon-syntax" + ("used for composition" + (pre-compile '(no:eq? a b)) + ((fn args (no (apply eq? args))) a b)) + + ("used for composition" + (pre-compile '(x:y a b)) + ((fn args (x (apply y args))) a b))) + + (suite "bang-colon syntax" + ("special combination with bang" + (pre-compile '(!x:y a b)) + ((fn args (no (x (apply y args)))) a b))) + ("expands 'let" (do (def x+3*z (x y) (let y 3 (fn (z) (* (+ x y) z)))) @@ -182,10 +210,10 @@ ("handles nested unquote-splicing" ``(a ,,@(list '+ 1 2) b) `((a ,(+ 1 2) b))) ("returns nested quasiquotes" `(a b `(c d ,(+ 1 2) ,,(+ 3 4))) - (a b `(c d ,(+ 1 2) ,7))))) + (a b `(c d ,(+ 1 2) ,7)))) (suite "build-keyword-args" ("takes a list of lists and returns the list with the first item of each sublist quoted" (build-keyword-args '( (a 1) (b c) (d e "f" 22) )) ((list 'a 1) (list 'b c) (list 'd e "f" 22))))