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]))) -