Elixir介绍
示例
当您使用编写代码文档时@doc,可以提供如下代码示例:
# myproject/lib/my_module.exs
defmodule MyModule do
@doc """
Given a number, returns `true` if the number is even, otherwise `false`.
## Example
iex> MyModule.even?(2)
true
iex> MyModule.even?(3)
false
"""
def even?(number) do
rem(number, 2) == 0
end
end您可以将代码示例作为测试用例添加到您的一个测试套件中:
# myproject/test/doc_test.exs defmodule DocTest do use ExUnit.Case doctest MyModule end
然后,您可以使用进行测试mixtest。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短