Skip to content

Commit cb4a98d

Browse files
committed
Add test for spec error fmt messages
1 parent 9265453 commit cb4a98d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/gradient/elixir_fmt_test.exs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,27 @@ defmodule Gradient.ElixirFmtTest do
239239
end
240240
end
241241

242+
describe "spec" do
243+
test "name doesn't match the function name" do
244+
msg =
245+
{:spec_error, :wrong_spec_name, 3, :convert, 1}
246+
|> ElixirFmt.format_error([])
247+
|> :erlang.iolist_to_binary()
248+
249+
assert "The spec convert/1 on line 3 doesn't match the function name/arity\n" = msg
250+
end
251+
252+
test "follows another spec" do
253+
msg =
254+
{:spec_error, :spec_after_spec, 3, :convert, 1}
255+
|> ElixirFmt.format_error([])
256+
|> :erlang.iolist_to_binary()
257+
258+
assert "The spec convert/1 on line 3 follows another spec when only one spec per function clause is allowed\n" =
259+
msg
260+
end
261+
end
262+
242263
@tag :skip
243264
test "format_expr_type_error/4" do
244265
opts = [forms: basic_erlang_forms()]

0 commit comments

Comments
 (0)