Pattern Matching
Pattern matching em variáveis
defmodule SimpleTest do
use ExUnit.Case
test "simple tests about pattern matching" do
person = Person.create("My Name", :no_binary)
assert person.name == "My Name"
assert person.genre == :no_binary
end
end$ mix test
warning: Person.create/2 is undefined (module Person is not available or is yet to be defined)
test/phrases_test.exs:6: SimpleTest."test simple tests about pattern matching"/1
.
1) test simple tests about pattern matching (SimpleTest)
test/phrases_test.exs:4
** (UndefinedFunctionError) function Person.create/2 is undefined (module Person is not available)
code: person = Person.create("My Name", :no_binary)defmodule Document do
def render(_id, _type) do
"Rendering txt"
end
end
stacktrace:
Person.create("My Name", :no_binary)
test/phrases_test.exs:6: (test)
.
Finished in 0.04 seconds (0.00s async, 0.04s sync)
3 tests, 1 failurePattern matching em funções
Conclusão
Last updated