Skip to content

Commit 11d9944

Browse files
committed
fix the tests
1 parent 1fed203 commit 11d9944

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

lib/elixir/lib/exception.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ defmodule Protocol.UndefinedError do
20012001
value_type(value) <>
20022002
maybe_description(description) <>
20032003
maybe_available(protocol) <>
2004-
"\n\nGot value: #{inspect(value, pretty: true)}"
2004+
"\n\nGot value:\n\n#{inspect(value, pretty: true)}"
20052005
end
20062006

20072007
defp value_type(%{__struct__: struct}), do: "#{inspect(struct)} (a struct)"

lib/elixir/test/elixir/inspect_test.exs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ defmodule Inspect.MapTest do
526526
# Inspect.Error is raised here when we tried to print the error message
527527
# called by another exception (Protocol.UndefinedError in this case)
528528
exception_message = ~s'''
529-
protocol Enumerable not implemented for #Inspect.Error<
529+
protocol Enumerable not implemented for type Inspect.MapTest.Failing (a struct)
530+
531+
Got value:
532+
533+
#Inspect.Error<
530534
got ArgumentError with message:
531535
532536
"""
@@ -926,7 +930,11 @@ defmodule Inspect.CustomProtocolTest do
926930
got Protocol.UndefinedError with message:
927931
928932
"""
929-
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for %Inspect.CustomProtocolTest.MissingImplementation{} of type Inspect.CustomProtocolTest.MissingImplementation (a struct)
933+
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for type Inspect.CustomProtocolTest.MissingImplementation (a struct)
934+
935+
Got value:
936+
937+
%Inspect.CustomProtocolTest.MissingImplementation{}
930938
"""
931939
932940
while inspecting:
@@ -953,7 +961,11 @@ defmodule Inspect.CustomProtocolTest do
953961
got Protocol.UndefinedError with message:
954962
955963
"""
956-
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for %Inspect.CustomProtocolTest.MissingImplementation{} of type Inspect.CustomProtocolTest.MissingImplementation (a struct)
964+
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for type Inspect.CustomProtocolTest.MissingImplementation (a struct)
965+
966+
Got value:
967+
968+
%Inspect.CustomProtocolTest.MissingImplementation{}
957969
"""
958970
959971
while inspecting:

lib/elixir/test/elixir/protocol/consolidation_test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ defmodule Protocol.ConsolidationTest do
182182

183183
test "protocol not implemented" do
184184
message =
185-
"protocol Protocol.ConsolidationTest.Sample not implemented for :foo of type Atom. " <>
186-
"This protocol is implemented for the following type(s): Protocol.ConsolidationTest.ImplStruct"
185+
"protocol Protocol.ConsolidationTest.Sample not implemented for type Atom. " <>
186+
"This protocol is implemented for the following type(s): Protocol.ConsolidationTest.ImplStruct" <>
187+
"\n\nGot value:\n\n:foo"
187188

188189
assert_raise Protocol.UndefinedError, message, fn ->
189190
sample = String.to_atom("Elixir.Protocol.ConsolidationTest.Sample")

lib/elixir/test/elixir/protocol_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ defmodule ProtocolTest do
113113
end
114114

115115
test "protocol not implemented" do
116-
message = "protocol ProtocolTest.Sample not implemented for :foo of type Atom"
116+
message = "protocol ProtocolTest.Sample not implemented for type Atom\n\nGot value:\n\n:foo"
117117

118118
assert_raise Protocol.UndefinedError, message, fn ->
119119
sample = String.to_atom("Elixir.ProtocolTest.Sample")

lib/elixir/test/elixir/string/chars_test.exs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,41 @@ defmodule String.Chars.ErrorsTest do
105105

106106
test "bitstring" do
107107
message =
108-
"protocol String.Chars not implemented for <<0, 1::size(4)>> of type BitString, cannot convert a bitstring to a string"
108+
"protocol String.Chars not implemented for type BitString, cannot convert a bitstring to a string\n\nGot value:\n\n<<0, 1::size(4)>>"
109109

110110
assert_raise Protocol.UndefinedError, message, fn ->
111111
to_string(<<1::size(12)-integer-signed>>)
112112
end
113113
end
114114

115115
test "tuple" do
116-
message = "protocol String.Chars not implemented for {1, 2, 3} of type Tuple"
116+
message = "protocol String.Chars not implemented for type Tuple\n\nGot value:\n\n{1, 2, 3}"
117117

118118
assert_raise Protocol.UndefinedError, message, fn ->
119119
to_string({1, 2, 3})
120120
end
121121
end
122122

123123
test "PID" do
124-
message = ~r"^protocol String\.Chars not implemented for #PID<.+?> of type PID$"
124+
message = ~r"^protocol String\.Chars not implemented for type PID\n\nGot value:\n\n#PID<.+?>$"
125125

126126
assert_raise Protocol.UndefinedError, message, fn ->
127127
to_string(self())
128128
end
129129
end
130130

131131
test "ref" do
132-
message = ~r"^protocol String\.Chars not implemented for #Reference<.+?> of type Reference$"
132+
message =
133+
~r"^protocol String\.Chars not implemented for type Reference\n\nGot value:\n\n#Reference<.+?>$"
133134

134135
assert_raise Protocol.UndefinedError, message, fn ->
135136
to_string(make_ref()) == ""
136137
end
137138
end
138139

139140
test "function" do
140-
message = ~r"^protocol String\.Chars not implemented for #Function<.+?> of type Function$"
141+
message =
142+
~r"^protocol String\.Chars not implemented for type Function\n\nGot value:\n\n#Function<.+?>$"
141143

142144
assert_raise Protocol.UndefinedError, message, fn ->
143145
to_string(fn -> nil end)
@@ -146,7 +148,9 @@ defmodule String.Chars.ErrorsTest do
146148

147149
test "port" do
148150
[port | _] = Port.list()
149-
message = ~r"^protocol String\.Chars not implemented for #Port<.+?> of type Port$"
151+
152+
message =
153+
~r"^protocol String\.Chars not implemented for type Port\n\nGot value:\n\n#Port<.+?>$"
150154

151155
assert_raise Protocol.UndefinedError, message, fn ->
152156
to_string(port)
@@ -155,7 +159,7 @@ defmodule String.Chars.ErrorsTest do
155159

156160
test "user-defined struct" do
157161
message =
158-
"protocol String\.Chars not implemented for %String.Chars.ErrorsTest.Foo{foo: \"bar\"} of type String.Chars.ErrorsTest.Foo (a struct)"
162+
"protocol String\.Chars not implemented for type String.Chars.ErrorsTest.Foo (a struct)\n\nGot value:\n\n%String.Chars.ErrorsTest.Foo{foo: \"bar\"}"
159163

160164
assert_raise Protocol.UndefinedError, message, fn ->
161165
to_string(%Foo{})

0 commit comments

Comments
 (0)