diff --git a/lib/ex_parameterized/params.ex b/lib/ex_parameterized/params.ex index e7f419c..f0dfbbc 100644 --- a/lib/ex_parameterized/params.ex +++ b/lib/ex_parameterized/params.ex @@ -51,7 +51,10 @@ defmodule ExUnit.Parameterized.Params do end end - defp param_with_index(list) do + defp param_with_index(list) when is_list(list) do Enum.zip(list, 0..Enum.count(list)) end + defp param_with_index(list) do + raise(ArgumentError, message: "Unsupported format") + end end diff --git a/lib/ex_parameterized/params_callback.ex b/lib/ex_parameterized/params_callback.ex index 22503c4..36bbfa1 100644 --- a/lib/ex_parameterized/params_callback.ex +++ b/lib/ex_parameterized/params_callback.ex @@ -54,7 +54,10 @@ defmodule ExUnit.Parameterized.ParamsCallback do end end - defp param_with_index(list) do + defp param_with_index(list) when is_list(list) do Enum.zip(list, 0..Enum.count(list)) end + defp param_with_index(list) do + raise(ArgumentError, message: "Unsupported format") + end end diff --git a/test/ex_parameterized_callback_test.exs b/test/ex_parameterized_callback_test.exs index 786e86f..6644a99 100644 --- a/test/ex_parameterized_callback_test.exs +++ b/test/ex_parameterized_callback_test.exs @@ -119,4 +119,13 @@ defmodule ExParameterizedParamsCallbackTest do "description for param2": {"hello", context[:hello], "hello and world"} ] end + + test_with_params "with function", fn p -> + p + end do + make = fn a -> a + 1 end + [ + {make.(1)} + ] + end end diff --git a/test/ex_parameterized_test.exs b/test/ex_parameterized_test.exs index 9699fcd..9d1c258 100644 --- a/test/ex_parameterized_test.exs +++ b/test/ex_parameterized_test.exs @@ -153,4 +153,13 @@ defmodule ExParameterizedTest do end do Enum.map([{["a", "b"]}], fn x -> x end) end + + test_with_params "with function", fn p -> + p + end do + make = fn a -> a + 1 end + [ + {make.(1)} + ] + end end