From 0bbce2a81959d8452bce8da96de6bb45b201ff43 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Sat, 11 May 2013 19:40:48 +0200 Subject: [PATCH] Add a native macros test --- tests/__init__.py | 1 + tests/native_tests/native_macros.hy | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/native_tests/native_macros.hy diff --git a/tests/__init__.py b/tests/__init__.py index 3290f8c..5a88209 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -4,6 +4,7 @@ import hy # noqa from .native_tests.defclass import * # noqa from .native_tests.math import * # noqa +from .native_tests.native_macros import * from .native_tests.quote import * # noqa from .native_tests.language import * # noqa from .native_tests.unless import * # noqa diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy new file mode 100644 index 0000000..7d4789a --- /dev/null +++ b/tests/native_tests/native_macros.hy @@ -0,0 +1,10 @@ +(defn test-rev-macro [] + "NATIVE: test stararged native macros" + (defmacro rev [&rest body] + "Execute the `body` statements in reverse" + (+ (quote (do)) (list (reversed body)))) + + (setv x []) + (rev (.append x 1) (.append x 2) (.append x 3)) + (assert (= x [3 2 1]))) +