Skip to content

Commit 635b77e

Browse files
committed
Add test on protocols
1 parent 51c0bcd commit 635b77e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/elixir/test/elixir/protocol_test.exs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ defmodule ProtocolTest do
8787
end
8888
end
8989

90+
test "built-in protocols" do
91+
builtin_protocols =
92+
for app <- ~w[eex elixir ex_unit iex logger mix]a,
93+
Application.ensure_loaded(app),
94+
module <- Application.spec(app, :modules),
95+
Code.ensure_loaded(module),
96+
function_exported?(module, :__protocol__, 1),
97+
do: module
98+
99+
# If this test fails, update:
100+
# * lib/elixir/lib/module/types/apply.ex
101+
# * lib/elixir/scripts/elixir_docs.ex
102+
assert Enum.sort(builtin_protocols) == [
103+
Collectable,
104+
Enumerable,
105+
IEx.Info,
106+
Inspect,
107+
JSON.Encoder,
108+
List.Chars,
109+
String.Chars
110+
]
111+
end
112+
90113
test "protocol implementations without any" do
91114
assert is_nil(Sample.impl_for(:foo))
92115
assert is_nil(Sample.impl_for(fn x -> x end))

0 commit comments

Comments
 (0)