Skip to content

Commit

Permalink
Pattern match in Funs is kind of cool
Browse files Browse the repository at this point in the history
  • Loading branch information
davoclavo committed Aug 25, 2016
1 parent 9f7d8b4 commit ec3d6d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/files/Elm.Native.Utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
-export([ append/0 ]).

append() ->
elmer_runtime:partial(fun (V_a, V_b) ->
erlang:iolist_to_binary([V_a, V_b])
elmer_runtime:partial(fun (Xs, Ys) when is_binary(Xs) -> erlang:iolist_to_binary([Xs, Ys]);
(Xs, Ys) when is_list(Xs) -> lists:append(Xs, Ys)
end, 2).
4 changes: 3 additions & 1 deletion test/native_elmer_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ runs_RunExample_test() ->
%% TODO Figure out where to put Native modules
%% TODO Namespace loaded modules to 'Elm.ModuleName'
Result = ('Elm.RunExample':greet())([<<"doodie">>]),
?assertEqual(<<"Howdy, doodie">>, Result).
?assertEqual(<<"Howdy, doodie">>, Result),
Result2 = ('Elm.Native.Utils':append())([[1,2],[3,4]]),
?assertEqual([1,2,3,4], Result2).

-endif. %% TEST

0 comments on commit ec3d6d3

Please sign in to comment.