I have a macro that can raise but I am having trouble testing it. I tried the following thinking it would work, but doesn’t seem to. Any help on how to test this at compile time?
assert_raise ArgumentError, fn ->
Code.eval_quoted(quote do
defmodule MyMod do
use MyMacro
my_macro_that_will_raise
end
end)
end
I know I’m resurrecting an old thread here, but I’ve noticed that this isn’t necessary anymore? At least, assert_raise seems to work just fine if I use a macro in assert_raise(ArgumentError, fn -> macro_that_raises() end). Has this changed since July 2017 or are there some cases for which assert_raise works and others for which it doesn’t?
Yep, the first is compile-time and the second is run-time, usually, the second one could potentially become compile-time as well depending on what else is being done and where.