Skip to content

Commit 3f5e6de

Browse files
author
José Valim
committed
Merge pull request #1126 from alco/1125-test
Add tests for body-less functions
2 parents 8460488 + 3c9f486 commit 3f5e6de

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/elixir/test/elixir/kernel/errors_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,16 @@ defmodule Kernel.ErrorsTest do
270270
format_rescue('case [] do; [] when something_that_does_not_exist == [] -> :ok; end')
271271
end
272272

273+
test :bodyless_function do
274+
assert {{:module, M, _, {:foo,1}}, [], _} =
275+
:elixir.eval(to_char_list("defmodule M do\ndef foo(n)\nend"), [])
276+
end
277+
278+
test :bodyless_function_with_guard do
279+
assert "nofile:2: missing keyword do in def" =
280+
format_rescue("defmodule Foo do\ndef foo(n) when is_number(n)\nend")
281+
end
282+
273283
test :invalid_function_on_match do
274284
assert "nofile:1: cannot invoke function something_that_does_not_exist/0 inside match" =
275285
format_rescue('case [] do; something_that_does_not_exist() -> :ok; end')

0 commit comments

Comments
 (0)