Improve and enforce naming of koans at compile time

This commit is contained in:
Felipe Sere
2016-04-10 19:14:35 +01:00
parent 98ab1a0e26
commit 6752ec758c
6 changed files with 23 additions and 17 deletions

View File

@@ -1,5 +1,12 @@
defmodule Koans do
defp valid_name(name) do
Regex.match?(~r/([A-Z]|\.\.\.).+/, name)
end
defmacro koan(name, body) do
if not valid_name(name) do
raise "Name does not start with a capital ltter: #{name}"
end
compiled_name = String.to_atom(name)
number_of_args = Blanks.count(body)
quote do