From 06511fe303aa2d3aff82d5b689fe21b592d64d80 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Thu, 4 Apr 2013 11:06:03 +0200 Subject: [PATCH] Add do-in-defn tests --- tests/native_tests/language.hy | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 0bb9f77..0538f44 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -245,3 +245,22 @@ (defn my-fun [x] (+ x 1)) (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))))