@@ -8,8 +8,7 @@ defmodule ExUnit.AssertionError do
8
8
defexception left: @ no_value ,
9
9
right: @ no_value ,
10
10
message: @ no_value ,
11
- expr: @ no_value ,
12
- binding: @ no_value
11
+ expr: @ no_value
13
12
14
13
@ doc """
15
14
Indicates no meaningful value for a field.
@@ -105,7 +104,6 @@ defmodule ExUnit.Assertions do
105
104
left = Macro . expand ( left , __CALLER__ )
106
105
vars = collect_vars_from_pattern ( left )
107
106
pins = collect_pins_from_pattern ( left , __CALLER__ . vars )
108
- rhs_binding = collect_vars_used_in_expression ( right , __CALLER__ . vars )
109
107
110
108
# If the match works, we need to check if the value
111
109
# is not nil nor false. We need to rewrite the if
@@ -116,7 +114,6 @@ defmodule ExUnit.Assertions do
116
114
x when x in [ nil , false ] ->
117
115
raise ExUnit.AssertionError ,
118
116
expr: expr ,
119
- binding: unquote ( rhs_binding ) ,
120
117
message: "Expected truthy, got #{ inspect right } "
121
118
_ ->
122
119
:ok
@@ -133,7 +130,6 @@ defmodule ExUnit.Assertions do
133
130
raise ExUnit.AssertionError ,
134
131
right: right ,
135
132
expr: expr ,
136
- binding: unquote ( rhs_binding ) ,
137
133
message: "match (=) failed" <>
138
134
ExUnit.Assertions . __pins__ ( unquote ( pins ) )
139
135
end
@@ -151,14 +147,12 @@ defmodule ExUnit.Assertions do
151
147
code = escape_quoted ( :assert , assertion )
152
148
match? = { :match? , meta , [ left , Macro . var ( :right , __MODULE__ ) ] }
153
149
pins = collect_pins_from_pattern ( left , __CALLER__ . vars )
154
- rhs_binding = collect_vars_used_in_expression ( right , __CALLER__ . vars )
155
150
156
151
quote do
157
152
right = unquote ( right )
158
153
assert unquote ( match? ) ,
159
154
right: right ,
160
155
expr: unquote ( code ) ,
161
- binding: unquote ( rhs_binding ) ,
162
156
message: "match (match?) failed" <>
163
157
ExUnit.Assertions . __pins__ ( unquote ( pins ) )
164
158
end
@@ -167,15 +161,12 @@ defmodule ExUnit.Assertions do
167
161
defmacro assert ( assertion ) do
168
162
case translate_assertion ( :assert , assertion , __CALLER__ ) do
169
163
nil ->
170
- binding = collect_vars_used_in_expression ( assertion , __CALLER__ . vars )
171
-
172
164
quote do
173
165
value = unquote ( assertion )
174
166
175
167
unless value do
176
168
raise ExUnit.AssertionError ,
177
169
expr: unquote ( escape_quoted ( :assert , assertion ) ) ,
178
- binding: unquote ( binding ) ,
179
170
message: "Expected truthy, got #{ inspect value } "
180
171
end
181
172
@@ -212,14 +203,12 @@ defmodule ExUnit.Assertions do
212
203
code = escape_quoted ( :refute , assertion )
213
204
match? = { :match? , meta , [ left , Macro . var ( :right , __MODULE__ ) ] }
214
205
pins = collect_pins_from_pattern ( left , __CALLER__ . vars )
215
- rhs_binding = collect_vars_used_in_expression ( right , __CALLER__ . vars )
216
206
217
207
quote do
218
208
right = unquote ( right )
219
209
refute unquote ( match? ) ,
220
210
right: right ,
221
211
expr: unquote ( code ) ,
222
- binding: unquote ( rhs_binding ) ,
223
212
message: "match (match?) succeeded, but should have failed" <>
224
213
ExUnit.Assertions . __pins__ ( unquote ( pins ) )
225
214
end
@@ -228,15 +217,12 @@ defmodule ExUnit.Assertions do
228
217
defmacro refute ( assertion ) do
229
218
case translate_assertion ( :refute , assertion , __CALLER__ ) do
230
219
nil ->
231
- binding = collect_vars_used_in_expression ( assertion , __CALLER__ . vars )
232
-
233
220
quote do
234
221
value = unquote ( assertion )
235
222
236
223
if value do
237
224
raise ExUnit.AssertionError ,
238
225
expr: unquote ( escape_quoted ( :refute , assertion ) ) ,
239
- binding: unquote ( binding ) ,
240
226
message: "Expected false or nil, got #{ inspect value } "
241
227
end
242
228
@@ -277,26 +263,19 @@ defmodule ExUnit.Assertions do
277
263
defp translate_assertion ( kind , { _ , _ , [ left , right ] } = expr , call , message , true , caller ) do
278
264
expr = escape_quoted ( kind , expr )
279
265
280
- # We collect the binding for LHS/RHS separately because we want top-level
281
- # variables to not show up in the binding, but if we pass "expr" we're sure
282
- # there won't be any top-level variables.
283
- binding = Enum . uniq ( collect_vars_used_in_expression ( left , caller . vars ) ++ collect_vars_used_in_expression ( right , caller . vars ) )
284
-
285
266
quote do
286
267
left = unquote ( left )
287
268
right = unquote ( right )
288
269
if ExUnit.Assertions . __equal__? ( left , right ) do
289
270
assert false ,
290
271
left: left ,
291
272
expr: unquote ( expr ) ,
292
- binding: unquote ( binding ) ,
293
273
message: unquote ( message <> ", both sides are exactly equal" )
294
274
else
295
275
assert unquote ( call ) ,
296
276
left: left ,
297
277
right: right ,
298
278
expr: unquote ( expr ) ,
299
- binding: unquote ( binding ) ,
300
279
message: unquote ( message )
301
280
end
302
281
end
@@ -305,19 +284,13 @@ defmodule ExUnit.Assertions do
305
284
defp translate_assertion ( kind , { _ , _ , [ left , right ] } = expr , call , message , false , caller ) do
306
285
expr = escape_quoted ( kind , expr )
307
286
308
- # We collect the binding for LHS/RHS separately because we want top-level
309
- # variables to not show up in the binding, but if we pass "expr" we're sure
310
- # there won't be any top-level variables.
311
- binding = Enum . uniq ( collect_vars_used_in_expression ( left , caller . vars ) ++ collect_vars_used_in_expression ( right , caller . vars ) )
312
-
313
287
quote do
314
288
left = unquote ( left )
315
289
right = unquote ( right )
316
290
assert unquote ( call ) ,
317
291
left: left ,
318
292
right: right ,
319
293
expr: unquote ( expr ) ,
320
- binding: unquote ( binding ) ,
321
294
message: unquote ( message )
322
295
end
323
296
end
0 commit comments