From 99f62fb8b3080156b27334085bbdd4cdd79f17bc Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Thu, 4 Apr 2013 09:29:21 +0200 Subject: [PATCH] Add some tests for defn --- tests/native_tests/language.hy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 3e92e1e..0bb9f77 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -229,3 +229,19 @@ [2 4])) (assert (= (list-comp (, x y) (x (range 2) y (range 2))) [(, 0 0) (, 0 1) (, 1 0) (, 1 1)]))) + +(defn test-defn-order [] + "NATIVE: test defn evaluation order" + (setv acc []) + (defn my-fun [] + (.append acc "Foo") + (.append acc "Bar") + (.append acc "Baz")) + (my-fun) + (assert (= acc ["Foo" "Bar" "Baz"]))) + +(defn test-defn-return [] + "NATIVE: test defn return" + (defn my-fun [x] + (+ x 1)) + (assert (= 43 (my-fun 42))))