Skip to content

Commit c4113cd

Browse files
ggcampinhojosevalim
authored andcommitted
Improve protocol consolidation tests for docs (#7119)
`Code.get_docs/1` calls `:code.get_object_code/1` with the module and this returns the old binary instead the consolidated one.
1 parent 5294a73 commit c4113cd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/elixir/test/elixir/protocol_test.exs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,11 @@ defmodule Protocol.ConsolidationTest do
371371
end
372372

373373
test "consolidation keeps docs" do
374-
docs = Code.get_docs(Sample, :docs)
375-
assert {{:ok, 1}, _, :def, [{:term, _, nil}], "Ok"} = List.keyfind(docs, {:ok, 1}, 0)
374+
{:ok, {Sample, [{'ExDc', docs_bin}]}} = :beam_lib.chunks(@sample_binary, ['ExDc'])
375+
{:elixir_docs_v1, docs} = :erlang.binary_to_term(docs_bin)
376+
ok_doc = Keyword.get(docs, :docs) |> List.keyfind({:ok, 1}, 0)
377+
378+
assert {{:ok, 1}, _, :def, [{:term, _, nil}], "Ok"} = ok_doc
376379
end
377380

378381
test "consolidation keeps source" do

0 commit comments

Comments
 (0)