Anton Shestakov <engored@ya.ru>, Sat, 08 Mar 2014 23:46:38 +0900
Strictly speaking, rps_rules has no state.
test/rps5_tests.erl
Permissions: -rw-r--r--
-import(rps5, [get_hands/0, winning_hand/1, why/2]). -include_lib("eunit/include/eunit.hrl"). ?assertEqual(5, length(get_hands())). ?assertEqual(paper, winning_hand([rock, paper])), ?assertEqual(scissors, winning_hand([paper, scissors])), ?assertEqual(rock, winning_hand([scissors, rock])), ?assertEqual(rock, winning_hand([rock, rock, rock])), ?assertEqual(undefined, winning_hand([rock, paper, scissors])), ?assertEqual(paper, winning_hand([rock, paper, paper])), ?assertEqual(paper, winning_hand([rock, rock, paper])). ?assertEqual("smashes", why(spock, scissors)), ?assertEqual("lizard poisons spock, eats paper", why(lizard, [spock, paper])).