From 1327d5888227ce0bb8a691454d9e482ab8e1bfe1 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 10 Aug 2015 13:44:11 +0200 Subject: [PATCH] Add a few tests for various defn corner cases Closes #302. Signed-off-by: Gergely Nagy --- tests/compilers/test_ast.py | 8 ++++++++ tests/native_tests/language.hy | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index 4491f83..3b23b61 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -519,3 +519,11 @@ def test_attribute_access(): def test_cons_correct(): """Ensure cons gets compiled correctly""" can_compile("(cons a b)") + + +def test_defn(): + """Ensure that defn works correctly in various corner cases""" + cant_compile("(defn if [] 1)") + cant_compile("(defn \"hy\" [] 1)") + cant_compile("(defn :hy [] 1)") + can_compile("(defn &hy [] 1)") diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index d468533..ec771e6 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -673,6 +673,12 @@ (assert (= 43 (my-fun 42)))) +(defn test-defn-lambdakey [] + "NATIVE: test defn with a &symbol function name" + (defn &hy [] 1) + (assert (= (&hy) 1))) + + (defn test-defn-do [] "NATIVE: test defn evaluation order with do" (setv acc [])