Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 19, 2024
1 parent b5384ef commit 05296c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 5 additions & 3 deletions test/ex_doc/language/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,11 @@ defmodule ExDoc.Language.ErlangTest do
~s|foo(X, Y)|
end

test "nominal", c do
assert autolink_spec("-nominal foo() :: t().", c) ==
~s|foo() :: <a href="#t:t/0">t</a>().|
if System.otp_release() >= "28" do
test "nominal", c do
assert autolink_spec("-nominal foo() :: t().", c) ==
~s|foo() :: <a href="#t:t/0">t</a>().|
end
end

test "tuple", c do
Expand Down
25 changes: 13 additions & 12 deletions test/ex_doc/retriever/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule ExDoc.Retriever.ErlangTest do
import TestHelper

@moduletag :tmp_dir
@nominal_type if System.otp_release() >= "28", do: :nominal, else: :type

describe "docs_from_modules/2" do
@describetag :otp_eep59
Expand Down Expand Up @@ -274,26 +275,26 @@ defmodule ExDoc.Retriever.ErlangTest do
end

test "types", c do
erlc(c, :mod, ~S"""
erlc(c, :mod, """
-module(mod).
-export_type([type1/0, equiv_type1/0, opaque1/0]).
-export_type([type1/0, equiv_type1/0, opaque1/0, nominal1/0]).
-doc("type1/0 docs.").
-type type1() :: atom().
-doc #{ equiv => type1/1 }.
-doc \#{equiv => type1/1}.
-type equiv_type1() :: atom().
-doc("opaque1/0 docs.").
-opaque opaque1() :: atom().
-doc("nominal1/0 docs.").
-nominal nominal1() :: atom().
-#{@nominal_type} nominal1() :: atom().
""")

config = %ExDoc.Config{source_url_pattern: "%{path}:%{line}"}
{[mod], []} = Retriever.docs_from_modules([:mod], config)
[equiv_type1, opaque1, nominal1, type1] = mod.typespecs
[equiv_type1, nominal1, opaque1, type1] = mod.typespecs

assert opaque1.id == "t:opaque1/0"
assert opaque1.type == :opaque
Expand All @@ -305,7 +306,7 @@ defmodule ExDoc.Retriever.ErlangTest do
"opaque1()"

assert nominal1.id == "t:nominal1/0"
assert nominal1.type == :nominal
assert nominal1.type == @nominal_type
assert nominal1.group == :Types
assert nominal1.signature == "nominal1()"
assert nominal1.doc |> DocAST.to_string() =~ "nominal1/0 docs."
Expand Down Expand Up @@ -486,24 +487,24 @@ defmodule ExDoc.Retriever.ErlangTest do
end

test "types", c do
erlc(c, :mod, ~S"""
erlc(c, :mod, """
%% @doc Docs.
-module(mod).
-export_type([type1/0, opaque1/0]).
-export_type([type1/0, opaque1/0, nominal1/0]).
-type type1() :: atom().
%% type1/0 docs.
-opaque opaque1() :: atom().
%% opaque1/0 docs.
-nominal nominal1() :: atom().
%% -doc("nominal1/0 docs.").
-#{@nominal_type} nominal1() :: atom().
%% nominal1/0 docs.
""")

config = %ExDoc.Config{source_url_pattern: "%{path}:%{line}"}
{[mod], []} = Retriever.docs_from_modules([:mod], config)
[opaque1, type1] = mod.typespecs
[nominal1, opaque1, type1] = mod.typespecs

assert opaque1.id == "t:opaque1/0"
assert opaque1.type == :opaque
Expand All @@ -514,7 +515,7 @@ defmodule ExDoc.Retriever.ErlangTest do
"opaque1()"

assert nominal1.id == "t:nominal1/0"
assert nominal1.type == :nominal
assert nominal1.type == @nominal_type
assert nominal1.group == :Types
assert nominal1.signature == "nominal1/0"
assert nominal1.doc |> DocAST.to_string() =~ "nominal1/0 docs."
Expand Down

0 comments on commit 05296c1

Please sign in to comment.