@@ -117,6 +117,7 @@ def initialize(assertion_proc_or_source, assertion_method, source_binding)
117117 @proc_local_variables = @assertion_proc . binding . eval ( 'local_variables' ) . map ( &:to_s )
118118 target_thread = Thread . current
119119 @trace_call = TracePoint . new ( :call , :c_call ) do |tp |
120+ next if @base_caller_length < 0
120121 locs = caller_locations
121122 if locs . length >= @base_caller_length +TARGET_INDEX_OFFSET and Thread . current == target_thread
122123 idx = -( @base_caller_length +TARGET_INDEX_OFFSET )
@@ -130,7 +131,7 @@ def initialize(assertion_proc_or_source, assertion_method, source_binding)
130131 end
131132 end
132133 trace_alias_method = PowerAssert . configuration . _trace_alias_method
133- @trace_return = TracePoint . new ( :return , :c_return ) do |tp |
134+ @trace = TracePoint . new ( :return , :c_return ) do |tp |
134135 method_id = ( trace_alias_method &&
135136 tp . event == :return &&
136137 tp . binding . eval ( '::Kernel.__callee__' ) ) || tp . method_id
@@ -155,7 +156,9 @@ def initialize(assertion_proc_or_source, assertion_method, source_binding)
155156 end
156157
157158 def yield
158- do_yield ( &@assertion_proc )
159+ @trace_call . enable do
160+ do_yield ( &@assertion_proc )
161+ end
159162 end
160163
161164 def message
@@ -165,14 +168,9 @@ def message
165168 private
166169
167170 def do_yield
168- @trace_return . enable do
169- begin
170- @base_caller_length = caller_locations . length
171- @trace_call . enable
172- yield
173- ensure
174- @trace_call . disable
175- end
171+ @trace . enable do
172+ @base_caller_length = caller_locations . length
173+ yield
176174 end
177175 end
178176
0 commit comments