@@ -8,8 +8,7 @@ defmodule ExUnit.AssertionError do
88 defexception left: @ no_value ,
99 right: @ no_value ,
1010 message: @ no_value ,
11- expr: @ no_value ,
12- binding: @ no_value
11+ expr: @ no_value
1312
1413 @ doc """
1514 Indicates no meaningful value for a field.
@@ -105,7 +104,6 @@ defmodule ExUnit.Assertions do
105104 left = Macro . expand ( left , __CALLER__ )
106105 vars = collect_vars_from_pattern ( left )
107106 pins = collect_pins_from_pattern ( left , __CALLER__ . vars )
108- rhs_binding = collect_vars_used_in_expression ( right , __CALLER__ . vars )
109107
110108 # If the match works, we need to check if the value
111109 # is not nil nor false. We need to rewrite the if
@@ -116,7 +114,6 @@ defmodule ExUnit.Assertions do
116114 x when x in [ nil , false ] ->
117115 raise ExUnit.AssertionError ,
118116 expr: expr ,
119- binding: unquote ( rhs_binding ) ,
120117 message: "Expected truthy, got #{ inspect right } "
121118 _ ->
122119 :ok
@@ -133,7 +130,6 @@ defmodule ExUnit.Assertions do
133130 raise ExUnit.AssertionError ,
134131 right: right ,
135132 expr: expr ,
136- binding: unquote ( rhs_binding ) ,
137133 message: "match (=) failed" <>
138134 ExUnit.Assertions . __pins__ ( unquote ( pins ) )
139135 end
@@ -151,14 +147,12 @@ defmodule ExUnit.Assertions do
151147 code = escape_quoted ( :assert , assertion )
152148 match? = { :match? , meta , [ left , Macro . var ( :right , __MODULE__ ) ] }
153149 pins = collect_pins_from_pattern ( left , __CALLER__ . vars )
154- rhs_binding = collect_vars_used_in_expression ( right , __CALLER__ . vars )
155150
156151 quote do
157152 right = unquote ( right )
158153 assert unquote ( match? ) ,
159154 right: right ,
160155 expr: unquote ( code ) ,
161- binding: unquote ( rhs_binding ) ,
162156 message: "match (match?) failed" <>
163157 ExUnit.Assertions . __pins__ ( unquote ( pins ) )
164158 end
@@ -167,15 +161,12 @@ defmodule ExUnit.Assertions do
167161 defmacro assert ( assertion ) do
168162 case translate_assertion ( :assert , assertion , __CALLER__ ) do
169163 nil ->
170- binding = collect_vars_used_in_expression ( assertion , __CALLER__ . vars )
171-
172164 quote do
173165 value = unquote ( assertion )
174166
175167 unless value do
176168 raise ExUnit.AssertionError ,
177169 expr: unquote ( escape_quoted ( :assert , assertion ) ) ,
178- binding: unquote ( binding ) ,
179170 message: "Expected truthy, got #{ inspect value } "
180171 end
181172
@@ -212,14 +203,12 @@ defmodule ExUnit.Assertions do
212203 code = escape_quoted ( :refute , assertion )
213204 match? = { :match? , meta , [ left , Macro . var ( :right , __MODULE__ ) ] }
214205 pins = collect_pins_from_pattern ( left , __CALLER__ . vars )
215- rhs_binding = collect_vars_used_in_expression ( right , __CALLER__ . vars )
216206
217207 quote do
218208 right = unquote ( right )
219209 refute unquote ( match? ) ,
220210 right: right ,
221211 expr: unquote ( code ) ,
222- binding: unquote ( rhs_binding ) ,
223212 message: "match (match?) succeeded, but should have failed" <>
224213 ExUnit.Assertions . __pins__ ( unquote ( pins ) )
225214 end
@@ -228,15 +217,12 @@ defmodule ExUnit.Assertions do
228217 defmacro refute ( assertion ) do
229218 case translate_assertion ( :refute , assertion , __CALLER__ ) do
230219 nil ->
231- binding = collect_vars_used_in_expression ( assertion , __CALLER__ . vars )
232-
233220 quote do
234221 value = unquote ( assertion )
235222
236223 if value do
237224 raise ExUnit.AssertionError ,
238225 expr: unquote ( escape_quoted ( :refute , assertion ) ) ,
239- binding: unquote ( binding ) ,
240226 message: "Expected false or nil, got #{ inspect value } "
241227 end
242228
@@ -277,26 +263,19 @@ defmodule ExUnit.Assertions do
277263 defp translate_assertion ( kind , { _ , _ , [ left , right ] } = expr , call , message , true , caller ) do
278264 expr = escape_quoted ( kind , expr )
279265
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-
285266 quote do
286267 left = unquote ( left )
287268 right = unquote ( right )
288269 if ExUnit.Assertions . __equal__? ( left , right ) do
289270 assert false ,
290271 left: left ,
291272 expr: unquote ( expr ) ,
292- binding: unquote ( binding ) ,
293273 message: unquote ( message <> ", both sides are exactly equal" )
294274 else
295275 assert unquote ( call ) ,
296276 left: left ,
297277 right: right ,
298278 expr: unquote ( expr ) ,
299- binding: unquote ( binding ) ,
300279 message: unquote ( message )
301280 end
302281 end
@@ -305,19 +284,13 @@ defmodule ExUnit.Assertions do
305284 defp translate_assertion ( kind , { _ , _ , [ left , right ] } = expr , call , message , false , caller ) do
306285 expr = escape_quoted ( kind , expr )
307286
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-
313287 quote do
314288 left = unquote ( left )
315289 right = unquote ( right )
316290 assert unquote ( call ) ,
317291 left: left ,
318292 right: right ,
319293 expr: unquote ( expr ) ,
320- binding: unquote ( binding ) ,
321294 message: unquote ( message )
322295 end
323296 end
0 commit comments