(try (macroexpand-1 '(my-macro (ill-formed-arguments ...)))
false ;; shouldn't get here
(catch Exception _ true)) ;; whole expression should be true
As long as you know that the *right* exception is being thrown.
On Thu, Jan 22, 2015 at 4:41 PM, Scott Rabin <[email protected]> wrote:
> We have a few macros in my employer's codebase that throw compile-time
> errors when you've given them invalid configurations, and have generally
> simply tested the result of these macros and not necessarily the direct
> expansion of said macros. What we would like to do is *test* that the
> macro blows up; but unfortunately, since this happens before tests are run,
> the result is that the compiler just complains at you instead of telling
> you that a specific test failed.
>
> Is there a decent way to test for thrown exceptions from macros other than
> writing a few cases and saying "well, if the tests didn't even run, it's
> not right!"?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.