On Tue, Mar 17, 2009 at 5:06 PM, Sean <[email protected]> wrote:
>
> Hey everyone,
> I'm writing a macro library for myself, and I'm thinking about
> publishing it. Before I do so, I'd like to write & run some unit
> tests for it. I was hoping the crowd could chime in on how they test
> macros. Any links & examples would be great. Thanks!
>
>
Haven't gotten around to writing unit tests for macros, but if I did I think
I would use macroexpand-1 and assert that it expanded into the form I was
expecting. For example let's say I wanted to write a test for the 'defn'
macro
If it worked correctly then the following expression should be true
(= (macroexpand-1 '(defn foo [x y] (+ x y)))
'(def foo (clojure.core/fn ([x y] (+ x y)))))
and it is, because (defn foo [x y] (+ x y)) does in fact expand out to (def
foo (clojure.core/fn ([x y] (+ x y))))
--
Cosmin Stejerean
http://offbytwo.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---