Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Commit

Permalink
revert fix_private_attribute (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa authored Jan 1, 2018
1 parent 786ccd7 commit 224ec84
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 62 deletions.
18 changes: 1 addition & 17 deletions lib/ex_parameterized/params.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ defmodule ExUnit.Parameterized.Params do
[{:{}, _, [{:%{}, _, _}]}] ->
ast |> do_test_with(desc, fun)

# for @param
{:@, _, [{atom, _, _}]} ->
quote do
attr =
Module.get_attribute(unquote(__CALLER__.module), unquote(atom))
|> Macro.escape()

# [{:test, [],
# ["'bad': number of 0",
# [do: {{:., [],
# [#Function<1.14669326 in file:test/ex_parameterized_test.exs>]}, [],
# [1]}]]}]
do_test_with(attr, unquote(desc), unquote(fun))
# If we can run the above AST, test will run.
end

_ ->
try do
{params, _} = Code.eval_quoted(params_ast)
Expand All @@ -37,7 +21,7 @@ defmodule ExUnit.Parameterized.Params do
end
end

def do_test_with(ast, desc, fun) do
defp do_test_with(ast, desc, fun) do
ast
|> param_with_index()
|> Enum.map(fn param ->
Expand Down
18 changes: 1 addition & 17 deletions lib/ex_parameterized/params_callback.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ defmodule ExUnit.Parameterized.ParamsCallback do
[{:{}, _, [{:%{}, _, _}]}] ->
ast |> do_test_with(desc, context, fun)

# for @param
{:@, _, [{atom, _, _}]} ->
quote do
attr =
Module.get_attribute(unquote(__CALLER__.module), unquote(atom))
|> Macro.escape()

# [{:test, [],
# ["'bad': number of 0",
# [do: {{:., [],
# [#Function<1.14669326 in file:test/ex_parameterized_test.exs>]}, [],
# [1]}]]}]
do_test_with(attr, unquote(desc), unquote(fun))
# If we can run the above AST, test will run.
end

_ ->
try do
{params, _} = params_ast |> Code.eval_quoted()
Expand All @@ -40,7 +24,7 @@ defmodule ExUnit.Parameterized.ParamsCallback do
end
end

def do_test_with(ast, desc, context, fun) do
defp do_test_with(ast, desc, context, fun) do
ast
|> param_with_index()
|> Enum.map(fn param ->
Expand Down
14 changes: 0 additions & 14 deletions test/ex_parameterized_callback_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,4 @@ defmodule ExParameterizedParamsCallbackTest do
"description for param2": {"hello", context[:hello], "hello and world"}
]
end

@params [{1}]
test_with_params "bad", context, fn a ->
assert a == 1
end do
@params
end

@params2 [{1}, {1}]
test_with_params "bad", context, fn a ->
assert a == 1
end do
@params2
end
end
14 changes: 0 additions & 14 deletions test/ex_parameterized_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,4 @@ defmodule ExParameterizedTest do
end do
Enum.map([{["a", "b"]}], fn x -> x end)
end

@params [{1}]
test_with_params "bad", fn a ->
assert a == 1
end do
@params
end

@params2 [{1}, {1}]
test_with_params "bad", fn a ->
assert a == 1
end do
@params2
end
end

0 comments on commit 224ec84

Please sign in to comment.