From 1e7c90c44ed75933000aabc131864a1d2d5dbb64 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Sat, 11 May 2013 20:57:46 +0200 Subject: [PATCH] Test requires from native code --- tests/native_tests/language.hy | 9 +++++++++ tests/native_tests/native_macros.hy | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index e0a1958..0254493 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -689,8 +689,17 @@ (defn test-require [] + "NATIVE: test requiring macros from python code" (try (assert (= "this won't happen" (qplah 1 2 3 4))) (catch [NameError])) (require tests.resources.tlib) (assert (= [1 2 3] (qplah 1 2 3)))) + + +(defn test-require-native [] + "NATIVE: test requiring macros from native code" + (require tests.native_tests.native_macros) + (setv x []) + (rev (.append x 1) (.append x 2) (.append x 3)) + (assert (= x [3 2 1]))) diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index e978a75..dcb3904 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -1,10 +1,10 @@ +(defmacro rev [&rest body] + "Execute the `body` statements in reverse" + (quasiquote (do (unquote-splice (list (reversed body)))))) + + (defn test-rev-macro [] "NATIVE: test stararged native macros" - (defmacro rev [&rest body] - "Execute the `body` statements in reverse" - (quasiquote (do (unquote-splice (list (reversed body))))))) - (setv x []) (rev (.append x 1) (.append x 2) (.append x 3)) (assert (= x [3 2 1]))) -