Skip to content

Commit adb0971

Browse files
committed
Add test cases for unary +
See #1931.
1 parent bf6c614 commit adb0971

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/ex_doc/language/erlang.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ defmodule ExDoc.Language.Erlang do
538538
{name, _, _}, acc when name in [:<<>>, :..] ->
539539
{nil, acc}
540540

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

545545
# fun() (spec_to_quoted expands it to (... -> any())

test/ex_doc/language/erlang_test.exs

+5
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ defmodule ExDoc.Language.ErlangTest do
767767
~s[foo() -> 1..255 | <a href="#t:t/0">t</a>().]
768768
end
769769

770+
test "integer unary", c do
771+
assert autolink_spec(~s"-spec f(LimitedInteger :: +1 | -1) -> t().", c) ==
772+
~s[f(LimitedInteger :: +1 | -1) -> <a href="#t:t/0">t</a>().]
773+
end
774+
770775
test "function - any", c do
771776
assert autolink_spec(~s"-spec foo() -> fun() | t().", c) ==
772777
~s[foo() -> fun() | <a href="#t:t/0">t</a>().]

0 commit comments

Comments
 (0)