Handle errors in tests functions as well

This allows failures to be passed back to the parent rather than the
koan process just dying and the parent stuck waiting for the result.
This commit is contained in:
Jay Hayes
2016-04-27 12:05:54 -05:00
parent 527b5ea028
commit 39f09e5c30

View File

@@ -33,8 +33,12 @@ defmodule Koans do
single_var = Blanks.replace(body, Macro.var(:answer, Koans))
quote do
def unquote(name)(answer) do
unquote(single_var)
:ok
try do
unquote(single_var)
:ok
rescue
e in _ -> e
end
end
end
end
@@ -44,8 +48,12 @@ defmodule Koans do
quote do
def unquote(name)({:multiple, answers}) do
converted = List.to_tuple(answers)
unquote(multi_var)
:ok
try do
unquote(multi_var)
:ok
rescue
e in _ -> e
end
end
end
end