Skip to content

Commit

Permalink
Add macro example to the retriever test
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Feb 20, 2022
1 parent 8e7ce49 commit 7e87f09
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/ex_doc/retriever/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ defmodule ExDoc.Retriever.ElixirTest do
@spec function() :: atom()
def function(), do: :ok
@doc "macro/0 docs."
@spec macro() :: Macro.t()
defmacro macro(), do: :ok
def empty_doc_and_specs(), do: :ok
@doc false
Expand All @@ -32,7 +36,7 @@ defmodule ExDoc.Retriever.ElixirTest do
title: "Mod",
type: :module,
typespecs: [],
docs: [empty_doc_and_specs, function],
docs: [empty_doc_and_specs, function, macro],
annotations: [:public]
} = mod

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

assert DocAST.to_string(function.doc) == "<p>function/0 docs.</p>"
assert Macro.to_string(spec) == "function() :: atom()"

assert %ExDoc.FunctionNode{
arity: 0,
annotations: ["macro"],
id: "macro/0",
signature: "macro()",
specs: [spec],
type: :macro
} = macro

assert DocAST.to_string(macro.doc) == "<p>macro/0 docs.</p>"
assert Macro.to_string(spec) == "macro() :: Macro.t()"

assert %ExDoc.FunctionNode{
id: "empty_doc_and_specs/0",
doc: nil,
specs: []
} = empty_doc_and_specs

assert Macro.to_string(spec) == "function() :: atom()"
end

test "Elixir functions with defaults", c do
Expand Down

0 comments on commit 7e87f09

Please sign in to comment.