Permalink
Browse files

Add tests for cmap.

  • Loading branch information...
arcusfelis committed Dec 23, 2012
1 parent 49c1cfc commit d736a027498f5e6d9edc2166f8e1f5b0084323b2
Showing with 8 additions and 1 deletion.
  1. +1 −1 src/lists2.erl
  2. +7 −0 test/lists2_proper_tests.erl
View
@@ -255,7 +255,7 @@ filter_head(F, [H|T]) when is_function(F, 1) ->
%% Call `F(X, C)' for each element in `Xs', where `X' is an element and
%% `C' is a counter from 1 to `length(Xs)'.
%% @end
-cmap(F, Xs) when is_function(F, 1), is_list(Xs) ->
+cmap(F, Xs) when is_function(F, 2), is_list(Xs) ->
cmap(F, Xs, 1).
@@ -45,3 +45,10 @@ map_group_with_test_() ->
[1,2,4,5,3]),
[{0, ["2", "4"]}, {1, ["1", "5", "3"]}])
].
+
+cmap_test_() ->
+ [?_assertEqual(lists2:
+ cmap(fun(X, N) -> atom_to_list(X) ++ integer_to_list(N) end,
+ [a,b,c]),
+ ["a1", "b2", "c3"])
+ ].

0 comments on commit d736a02

Please sign in to comment.