Add do-in-defn tests

This commit is contained in:
Nicolas Dandrimont 2013-04-04 11:06:03 +02:00
parent 940afcafa9
commit 06511fe303

View File

@ -245,3 +245,22 @@
(defn my-fun [x] (defn my-fun [x]
(+ x 1)) (+ x 1))
(assert (= 43 (my-fun 42)))) (assert (= 43 (my-fun 42))))
(defn test-defn-do []
"NATIVE: test defn evaluation order with do"
(setv acc [])
(defn my-fun []
(do
(.append acc "Foo")
(.append acc "Bar")
(.append acc "Baz")))
(my-fun)
(assert (= acc ["Foo" "Bar" "Baz"])))
(defn test-defn-do-return []
"NATIVE: test defn return with do"
(defn my-fun [x]
(do
(+ x 42) ; noop
(+ x 1)))
(assert (= 43 (my-fun 42))))