File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,12 @@ defmodule Inspect.Algebra do
110
110
if elem ( opts , Inspect.Opts . __record__ ( :index , :records ) ) do
111
111
try do
112
112
Inspect . inspect ( arg , opts )
113
- catch
114
- _ , _ -> Inspect.Tuple . inspect ( arg , opts )
113
+ rescue
114
+ e ->
115
+ res = Inspect.Tuple . inspect ( arg , opts )
116
+ IO . puts :stderr , "** (Inspect.Error) Got #{ inspect e . __record__ ( :name ) } with message " <>
117
+ "#{ e . message } while inspecting #{ pretty ( res , opts . width ) } "
118
+ res
115
119
end
116
120
else
117
121
Inspect.Tuple . inspect ( arg , opts )
Original file line number Diff line number Diff line change @@ -156,20 +156,20 @@ defmodule Inspect.TupleTest do
156
156
assert inspect ( RuntimeError . new ) == "RuntimeError[message: \" runtime error\" ]"
157
157
end
158
158
159
- defrecord :something , [ :a , :b ]
160
-
161
- test :non_module_record do
162
- # They are on purpose not treated as Elixir records
163
- # otherwise it affects inspect performance very strongly
164
- assert inspect ( :something . new ) == "{:something, nil, nil}"
165
- end
166
-
167
159
defrecord Rec , value: 1
168
160
169
161
test :two_items_record do
170
162
assert inspect ( { Rec [ value : 1 ] , 1 } ) == "{Inspect.TupleTest.Rec[value: 1], 1}"
171
163
end
172
164
165
+ test :false_positives do
166
+ import ExUnit.CaptureIO
167
+
168
+ assert capture_io ( :stderr , fn ->
169
+ assert inspect ( { Range , nil } ) == "{Range, nil}"
170
+ end ) =~ "** (Inspect.Error) Got FunctionClauseError with message no function clause matching in Inspect.Range.inspect/2"
171
+ end
172
+
173
173
test :empty do
174
174
assert inspect ( { } ) == "{}"
175
175
end
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ defmodule RangeTest do
45
45
test :inspect do
46
46
assert inspect ( 1 .. 3 ) == "1..3"
47
47
assert inspect ( 3 .. 1 ) == "3..1"
48
- assert inspect ( { Range , nil } ) == "{Range, nil}"
49
48
end
50
49
51
50
defp not_range do
You can’t perform that action at this time.
0 commit comments