2018-10-23 20:06:22 +02:00
|
|
|
(setv module-name-var "tests.resources.macros")
|
|
|
|
|
2018-03-19 22:40:10 +01:00
|
|
|
(defmacro thread-set-ab []
|
|
|
|
(defn f [&rest args] (.join "" (+ (, "a") args)))
|
|
|
|
(setv variable (HySymbol (-> "b" (f))))
|
|
|
|
`(setv ~variable 2))
|
|
|
|
|
|
|
|
(defmacro threadtail-set-cd []
|
|
|
|
(defn f [&rest args] (.join "" (+ (, "c") args)))
|
|
|
|
(setv variable (HySymbol (->> "d" (f))))
|
|
|
|
`(setv ~variable 5))
|
2018-07-26 00:13:05 +02:00
|
|
|
|
|
|
|
(defmacro test-macro []
|
|
|
|
'(setv blah 1))
|
2018-10-23 20:06:22 +02:00
|
|
|
|
|
|
|
(defmacro nonlocal-test-macro [x]
|
|
|
|
"When called from `macro-with-require`'s macro(s), the first instance of
|
|
|
|
`module-name-var` should resolve to the value in the module where this is
|
|
|
|
defined, then the expansion namespace/module"
|
|
|
|
`(.format (+ "This macro was created in {}, expanded in {} "
|
|
|
|
"and passed the value {}.")
|
|
|
|
~module-name-var module-name-var ~x))
|