Skip to content

Commit 7e87f09

Browse files
committed
Add macro example to the retriever test
1 parent 8e7ce49 commit 7e87f09

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

test/ex_doc/retriever/elixir_test.exs

+18-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ defmodule ExDoc.Retriever.ElixirTest do
1616
@spec function() :: atom()
1717
def function(), do: :ok
1818
19+
@doc "macro/0 docs."
20+
@spec macro() :: Macro.t()
21+
defmacro macro(), do: :ok
22+
1923
def empty_doc_and_specs(), do: :ok
2024
2125
@doc false
@@ -32,7 +36,7 @@ defmodule ExDoc.Retriever.ElixirTest do
3236
title: "Mod",
3337
type: :module,
3438
typespecs: [],
35-
docs: [empty_doc_and_specs, function],
39+
docs: [empty_doc_and_specs, function, macro],
3640
annotations: [:public]
3741
} = mod
3842

@@ -56,14 +60,25 @@ defmodule ExDoc.Retriever.ElixirTest do
5660
} = function
5761

5862
assert DocAST.to_string(function.doc) == "<p>function/0 docs.</p>"
63+
assert Macro.to_string(spec) == "function() :: atom()"
64+
65+
assert %ExDoc.FunctionNode{
66+
arity: 0,
67+
annotations: ["macro"],
68+
id: "macro/0",
69+
signature: "macro()",
70+
specs: [spec],
71+
type: :macro
72+
} = macro
73+
74+
assert DocAST.to_string(macro.doc) == "<p>macro/0 docs.</p>"
75+
assert Macro.to_string(spec) == "macro() :: Macro.t()"
5976

6077
assert %ExDoc.FunctionNode{
6178
id: "empty_doc_and_specs/0",
6279
doc: nil,
6380
specs: []
6481
} = empty_doc_and_specs
65-
66-
assert Macro.to_string(spec) == "function() :: atom()"
6782
end
6883

6984
test "Elixir functions with defaults", c do

0 commit comments

Comments
 (0)