Closed josephwilk closed 10 years ago
Test
defmodule Tennis.Game.Specs do use Amrita.Sweet import Tennis.Game fixtures = [ [[playerA: 0, playerB: 0], :playerA, [playerA: 15, playerB: 0]], [[playerA: 15, playerB: 0], :playerA, [playerA: 30, playerB: 0]], [[playerA: 30, playerB: 0], :playerA, [playerA: 40, playerB: 0]], [[playerA: 30, playerB: 0], :playerB, [playerA: 30, playerB: 15]], [[playerA: 40, playerB: 0], :playerA, Game[for: :playerA]], [[playerA: 0, playerB: 40], :playerB, Game[for: :playerB]], [[playerA: 0, playerB: 40], :playerA, [playerA: 15, playerB: 40]], [Game[for: :playerB], :playerA, Game[for: :playerB]], [Game[for: :playerA], :playerA, Game[for: :playerA]], [[playerA: 30, playerB: 40], :playerA, :deuce], [[playerA: 40, playerB: 30], :playerB, :deuce], [:deuce, :playerB, Advantage[for: :playerB]], [Advantage[for: :playerB], :playerA, :deuce], [Advantage[for: :playerA], :playerB, :deuce], [Advantage[for: :playerA], :playerA, Game[for: :playerA]], [Advantage[for: :playerB], :playerB, Game[for: :playerB]], ] lc [state, player, expected_state] inlist fixtures do @player player @state state @expected_state expected_state facts "For state <{inspect(state)}>" do fact "when <#{player}> scores, the new state should be <#{inspect(expected_state)}>" do score(@player, @state) |> equals @expected_state end end end end
And the error:
* (UndefinedFunctionError) undefined function: :"Elixir.String.Chars.<<>>".to_string/1 :"Elixir.String.Chars.<<>>".to_string({:<<>>, [line: 30], ["when <", {:::, [line: 30], [{{:., [line: 30], [Kernel, :to_string]}, [line: 30], [{:player, [line: 30], nil}]}, {:binary, [line: 30], nil}]}, "> scores, the new state should be <", {:::, [line: 30], [{{:., [line: 30], [Kernel, :to_string]}, [line: 30], [{:inspect, [line: 30], [{:expected_state, [line: 30], nil}]}]}, {:binary, [line: 30], nil}]}, ">"]}) deps/amrita/lib/amrita.ex:82: Amrita.Facts.fact_name/1 deps/amrita/lib/amrita.ex:121: Amrita.Facts."MACRO-fact"/5 test/tennis/game_test.exs:30: Amrita.Facts.fact/2 test/tennis/game_test.exs:29: Tennis.Game.Specs (module)
Note changing fact -> test solves the error.
Thanks @BjRo, your tennis example helped me spot and fix this bug!
Oh awesome!!! I totally forgot to ping you about that :-)
Test
And the error:
Note changing fact -> test solves the error.