mercredi 5 avril 2017

Elixir - How can you use an alias in doctest?

Is there a way to use a module alias in the doctests? I don't want to have to type out a long name every single time.

defmodule SomeLongModuleName.SubModule do
  alias SomeLongModuleName.SubModule, as: SubModule

  @doc """
      iex> SubModule.method(%{property_a: 1, property_b: 2) # CompileError
      3
  """
  def method(%{property_a: a, property_b: b) do
    a + b
  end
end

The example above shows a situation where I might want to use the alias to avoid long lines. Is it at all possible to use an alias in a doctest?

Aucun commentaire:

Enregistrer un commentaire