I have the following comment in my code:
@doc """
Divides a deck into a 'hand' and the remainder of the deck.
The `hand_size` argument indicates how many cards to 'deal' from the deck.
## Examples
iex> deck = Cards.create_deck(true)
iex> {hand, deck} = Cards.deal(deck, 1)
hand
["Two of Spades"]
"""
When I compile or recompile the file - all is well.
If I manually run the above listed iex>
lines, one at a time, all is well.
If I run mix test
I get this error report:
Compiling 1 file (.ex)
warning: variable "hand" does not exist and is being expanded to "hand()", please use parentheses to remove the ambiguity or change the variable name
(for doctest at) lib/cards.ex:55
warning: variable "deck" is unused
(for doctest at) lib/cards.ex:56
warning: variable "hand" is unused
(for doctest at) lib/cards.ex:56
== Compilation error in file test/cards_test.exs ==
** (CompileError) (for doctest at) lib/cards.ex:55: undefined function hand/0
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
(elixir) lib/code.ex:767: Code.require_file/2
(elixir) lib/kernel/parallel_compiler.ex:209: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
The reported lines 55 and 56 are the iex>
lines in my comment.
I’m using Elixir v1.7.1
The cards_test.exs file is unchanged from what mix generated for my project.
What have I done wrong?