1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c, vm.c, vm_eval.c, vm_insnhelper.c: fix issues about

return and c-return trace.  This issue skips (c-)return event
  with global jump such as break or return.  This fix make vm invoke
  hooks at stack rewind timing.  fix [ruby-core:27606] [Bug #2610].
* test/ruby/test_settracefunc.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2010-01-24 13:52:32 +00:00
parent 2979842520
commit 618445576f
6 changed files with 121 additions and 40 deletions

View file

@ -263,8 +263,31 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal([], events)
end
def test_break # [ruby-core:27606] [Bug #2610]
events = []
eval <<-EOF.gsub(/^.*?: /, "")
1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
2: events << [event, lineno, mid, klass]
3: })
4: [1,2,3].any? {|n| n}
8: set_trace_func(nil)
EOF
[["c-return", 3, :set_trace_func, Kernel],
["line", 4, __method__, self.class],
["c-call", 4, :any?, Enumerable],
["c-call", 4, :each, Array],
["line", 4, __method__, self.class],
["c-return", 4, :each, Array],
["c-return", 4, :any?, Enumerable],
["line", 5, __method__, self.class],
["c-call", 5, :set_trace_func, Kernel]].each{|e|
assert_equal(e, events.shift)
}
end
def test_invalid_proc
assert_raise(TypeError) { set_trace_func(1) }
assert_raise(TypeError) { set_trace_func(1) }
end
def test_raise_in_trace