Created
March 17, 2015 17:41
-
-
Save pfac/ba79941219c445113c18 to your computer and use it in GitHub Desktop.
Recursive macros failed attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Ninja.Macros do | |
defmacro __using__ [{ :name, value } | options] do | |
{:__block__, [], [ | |
quote do | |
@name unquote value | |
def name, do: @name | |
end, | |
__MODULE__.__using__(options) | |
] | |
} | |
end | |
defmacro __using__ _ do | |
end | |
end | |
defmodule Ninja.Macros.Fixture do | |
use Ninja.Macros, name: "test" | |
end | |
defmodule Ninja.Macros.Test do | |
use ExUnit.Case | |
alias Ninja.Macros.Fixture | |
test "#name returns the correct value" do | |
assert Fixture.name == "test" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment