KazuCocoa / ex_parameterized

This library support parameterized test with test_with_params macro.
https://github.com/KazuCocoa/ex_parameterized
MIT License
29 stars 7 forks source link

** (Protocol.UndefinedError) protocol Enumerable not implemented for #4

Closed artburkart closed 8 years ago

artburkart commented 8 years ago

Hi,

I like this library. Perhaps someone could help me use it. I'm a bit stumped by some behavior I'm seeing. If I define something like this:

  test_with_params "reverse_string",
    fn (str) ->
      (ImportedModule.reverse_string str) === (Enum.reverse str)
    end do
      Enum.map([{"hello"}], fn(x) -> x end)
  end

I get:

** (Protocol.UndefinedError) protocol Enumerable not implemented for {{:., [line: 26], [{:__aliases__, [counter: 0, line: 26], [:Enum]}, :map]}, [line: 26], [[{:{}, [line: 26], ["hello"]}], {:fn, [line: 26], [{:->, [line: 26], [[{:x, [line: 26], nil}], {:x, [line: 26], nil}]}]}]}

I know the production of the AST has something to do with the quoting and unquoting of my code, but it's unclear to me exactly what I need to do to satisfy the ex_paramterized library. Perhaps I can do something with:

http://elixir-lang.org/docs/stable/elixir/Code.html#eval_quoted/3

Any thoughts?

Cheers

KazuCocoa commented 8 years ago

Thanks for reporting issue ! I agree. I need to clear the reason and how to fix it.

In my use case, we should set like the following syntax:

  test_with_params "reverse_string",
    fn (str) ->
      (ImportedModule.reverse_string str) === (Enum.reverse str)
    end do
      [{ Enum.map([{"hello"}], fn(x) -> x end) }] # tuple(test data) nest into list.
  end

I'll update this library.

KazuCocoa commented 8 years ago

I'm going to release new version after implementing similar feature for ExUnit.Parameterized.ParamsCallback.

KazuCocoa commented 8 years ago

Thanks ! https://github.com/KazuCocoa/ex_parameterized/releases/tag/1.1.0