I want to be able to doctest the implementation of a protocol in Elixir.
Here is some example code:
defprotocol Size do
def size(data)
end
defmodule Foo do
defstruct []
defimpl Size do
@doc """
## Examples
iex> Size.size(%Foo{})
0
"""
def size(foo) do
0
end
end
end
This test code doesn't work (because it only finds functions defined in the Foo
module, outside of the defimpl
):
ExUnit.start()
defmodule FooTest do
use ExUnit.Case
doctest Foo
end
How can I test the defimpl
block?