Add a native macros test
This commit is contained in:
parent
4ffe20e853
commit
0bbce2a819
@ -4,6 +4,7 @@
|
|||||||
import hy # noqa
|
import hy # noqa
|
||||||
from .native_tests.defclass import * # noqa
|
from .native_tests.defclass import * # noqa
|
||||||
from .native_tests.math import * # noqa
|
from .native_tests.math import * # noqa
|
||||||
|
from .native_tests.native_macros import *
|
||||||
from .native_tests.quote import * # noqa
|
from .native_tests.quote import * # noqa
|
||||||
from .native_tests.language import * # noqa
|
from .native_tests.language import * # noqa
|
||||||
from .native_tests.unless import * # noqa
|
from .native_tests.unless import * # noqa
|
||||||
|
10
tests/native_tests/native_macros.hy
Normal file
10
tests/native_tests/native_macros.hy
Normal file
@ -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])))
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user