Skip to content

Commit

Permalink
Add test cases for unary +
Browse files Browse the repository at this point in the history
See #1931.
  • Loading branch information
josevalim committed Jul 7, 2024
1 parent bf6c614 commit adb0971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ex_doc/language/erlang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ defmodule ExDoc.Language.Erlang do
{name, _, _}, acc when name in [:<<>>, :..] ->
{nil, acc}

# -1
{:-, _, [int]}, acc when is_integer(int) ->
# -1, +1
{op, _, [int]}, acc when is_integer(int) and op in [:+, :-] ->
{nil, acc}

# fun() (spec_to_quoted expands it to (... -> any())
Expand Down
5 changes: 5 additions & 0 deletions test/ex_doc/language/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ defmodule ExDoc.Language.ErlangTest do
~s[foo() -> 1..255 | <a href="#t:t/0">t</a>().]
end

test "integer unary", c do
assert autolink_spec(~s"-spec f(LimitedInteger :: +1 | -1) -> t().", c) ==
~s[f(LimitedInteger :: +1 | -1) -> <a href="#t:t/0">t</a>().]
end

test "function - any", c do
assert autolink_spec(~s"-spec foo() -> fun() | t().", c) ==
~s[foo() -> fun() | <a href="#t:t/0">t</a>().]
Expand Down

0 comments on commit adb0971

Please sign in to comment.