Elixir Language
메타 프로그래밍
수색…
컴파일 타임에 테스트 생성
defmodule ATest do
use ExUnit.Case
[{1, 2, 3}, {10, 20, 40}, {100, 200, 300}]
|> Enum.each(fn {a, b, c} ->
test "#{a} + #{b} = #{c}" do
assert unquote(a) + unquote(b) = unquote(c)
end
end)
end
산출:
.
1) test 10 + 20 = 40 (Test.Test)
test.exs:6
match (=) failed
code: 10 + 20 = 40
rhs: 40
stacktrace:
test.exs:7
.
Finished in 0.1 seconds (0.1s on load, 0.00s on tests)
3 tests, 1 failure
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow