有没有办法在doctests中使用模块别名?我不想每次都输入一个长名字。Elixir - 如何在doctest中使用别名?
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
上面的例子显示了我可能想要使用别名来避免长行的情况。是否可以在doctest中使用别名?
我假设文档测试从全球运行命名空间,所以它将无法看到别名。 – Dylanthepiguy