--- a/Emakefile Sat Mar 01 23:07:50 2014 +0900
+++ b/Emakefile Sun Mar 02 00:02:23 2014 +0900
+{"src/*", [debug_info, {i,"include/"}, {outdir, "ebin/"}]}.
+{"test/*", [debug_info, {i,"include/"}, {outdir, "ebin/"}]}.
--- a/src/rps3.erl Sat Mar 01 23:07:50 2014 +0900
+++ b/src/rps3.erl Sun Mar 02 00:02:23 2014 +0900
- winning_hand/1, test_winning_hand/0]).
+-export([get_rules/0, winning_hand/1]).
get_rules() -> [rock, paper, scissors].
beats(H, lists:reverse(get_rules())).
- io:format("~w beats ~w.~n", [H, beats(H)])
- io:format("~w loses to ~w.~n", [H, loses(H)])
% rock, rock, rock -> rock
% rock, paper, scissors -> undefined
- [rock, paper, scissors],
- Winner = winning_hand(Hands),
- io:format("~w wins in ~w.~n", [Winner, Hands])
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/rps3_tests.erl Sun Mar 02 00:02:23 2014 +0900
+-include_lib("eunit/include/eunit.hrl").
+ ?assertEqual(length(rps3:get_rules()), 3).
+ ?assertEqual(rps3:winning_hand([rock, paper]), paper),
+ ?assertEqual(rps3:winning_hand([paper, scissors]), scissors),
+ ?assertEqual(rps3:winning_hand([scissors, rock]), rock),
+ ?assertEqual(rps3:winning_hand([rock, rock, rock]), rock),
+ ?assertEqual(rps3:winning_hand([rock, paper, scissors]), undefined),
+ ?assertEqual(rps3:winning_hand([rock, paper, paper]), paper),
+ ?assertEqual(rps3:winning_hand([rock, rock, paper]), paper).