mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
* compile.c (rb_iseq_compile_node): put start label of block after
trace (b_call). [Bug #9964] * test/ruby/test_settracefunc.rb: add a test. added assert_consistent_call_return() method check call/return consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
500f9777c9
commit
13f0b628d7
3 changed files with 60 additions and 1 deletions
|
@ -1308,4 +1308,52 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
[:c_return, :===],
|
||||
[:b_return, :test_rb_rescue]], events
|
||||
end
|
||||
|
||||
def method_prefix event
|
||||
case event
|
||||
when :call, :return
|
||||
:n
|
||||
when :c_call, :c_return
|
||||
:c
|
||||
when :b_call, :b_return
|
||||
:b
|
||||
end
|
||||
end
|
||||
|
||||
def method_label tp
|
||||
"#{method_prefix(tp.event)}##{tp.method_id}"
|
||||
end
|
||||
|
||||
def assert_consistent_call_return message='', check_events: nil
|
||||
check_events ||= %i(a_call a_return)
|
||||
call_events = []
|
||||
return_events = []
|
||||
|
||||
TracePoint.new(*check_events){|tp|
|
||||
next unless target_thread?
|
||||
|
||||
case tp.event.to_s
|
||||
when /call/
|
||||
call_events << method_label(tp)
|
||||
when /return/
|
||||
return_events << method_label(tp)
|
||||
end
|
||||
}.enable do
|
||||
yield
|
||||
end
|
||||
|
||||
assert_equal false, call_events.empty?
|
||||
assert_equal false, return_events.empty?
|
||||
assert_equal call_events, return_events.reverse, message
|
||||
end
|
||||
|
||||
def test_b_call_with_redo
|
||||
assert_consistent_call_return do
|
||||
i = 0
|
||||
1.times{
|
||||
break if (i+=1) > 10
|
||||
redo
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue