Initial commit
This commit is contained in:
22
lib/koans.ex
Normal file
22
lib/koans.ex
Normal file
@@ -0,0 +1,22 @@
|
||||
defmodule Koans do
|
||||
defmacro koan(name, body) do
|
||||
compiled_name = :"koan: #{name}"
|
||||
quote do
|
||||
def unquote(compiled_name)() do
|
||||
try do
|
||||
unquote(body)
|
||||
:ok
|
||||
rescue
|
||||
e in ExUnit.AssertionError -> e
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defmacro __using__(_) do
|
||||
quote do
|
||||
import Koans
|
||||
import ExUnit.Assertions
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user