diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-07 08:38:05 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-07 08:38:05 +0000 |
commit | 9961c29c25b54088569a7025ff80c8f7cd58a32d (patch) | |
tree | a4a4da8439c18262d305c716d3aa9db9ba96e8bd | |
parent | d8c66e05467c70fa3ee4a0e90bfce6f42f853fde (diff) | |
download | ruby-9961c29c25b54088569a7025ff80c8f7cd58a32d.tar.gz |
* eval.c (rb_call0): "return" event hook should be always executed
if event_hooks is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | test/ruby/test_settracefunc.rb | 93 |
3 files changed, 60 insertions, 42 deletions
@@ -1,3 +1,8 @@ +Thu Apr 7 17:24:17 2005 Shugo Maeda <shugo@ruby-lang.org> + + * eval.c (rb_call0): "return" event hook should be always executed + if event_hooks is set. + Thu Apr 7 14:33:09 2005 Kouhei Sutou <kou@cozmixng.org> * test/rss/test_maker_dc.rb (test_date): added a test for #date= @@ -5718,7 +5718,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper) int state; VALUE *local_vars; /* OK */ NODE *saved_cref = 0; - int hook_return = 0; PUSH_SCOPE(); @@ -5814,7 +5813,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper) if (event_hooks) { EXEC_EVENT_HOOK(RUBY_EVENT_CALL, b2, recv, id, klass); - hook_return = 1; } result = rb_eval(recv, body); } @@ -5827,7 +5825,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper) POP_CLASS(); POP_SCOPE(); ruby_cref = saved_cref; - if (hook_return) { + if (event_hooks) { EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, body, recv, id, klass); } switch (state) { diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index aa21812fa0..617df574e3 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1,7 +1,15 @@ require 'test/unit' class TestSetTraceFunc < Test::Unit::TestCase - def foo; end + def foo; end; + + def bar + events = [] + set_trace_func(Proc.new { |event, file, lineno, mid, bidning, klass| + events << [event, lineno, mid, klass] + }) + return events + end def test_event events = [] @@ -27,79 +35,79 @@ class TestSetTraceFunc < Test::Unit::TestCase eval("class Foo; end") set_trace_func nil - assert_equal(["line", 11, :test_event, TestSetTraceFunc], + assert_equal(["line", 19, :test_event, TestSetTraceFunc], events.shift) # a = 1 - assert_equal(["line", 12, :test_event, TestSetTraceFunc], + assert_equal(["line", 20, :test_event, TestSetTraceFunc], events.shift) # foo assert_equal(["call", 4, :foo, TestSetTraceFunc], events.shift) # foo assert_equal(["return", 4, :foo, TestSetTraceFunc], events.shift) # foo - assert_equal(["line", 13, :test_event, TestSetTraceFunc], + assert_equal(["line", 21, :test_event, TestSetTraceFunc], events.shift) # a - assert_equal(["line", 14, :test_event, TestSetTraceFunc], + assert_equal(["line", 22, :test_event, TestSetTraceFunc], events.shift) # b = 1 + 2 - assert_equal(["c-call", 14, :+, Fixnum], + assert_equal(["c-call", 22, :+, Fixnum], events.shift) # 1 + 2 - assert_equal(["c-return", 14, :+, Fixnum], + assert_equal(["c-return", 22, :+, Fixnum], events.shift) # 1 + 2 - assert_equal(["line", 15, :test_event, TestSetTraceFunc], + assert_equal(["line", 23, :test_event, TestSetTraceFunc], events.shift) # if b == 3 - assert_equal(["line", 15, :test_event, TestSetTraceFunc], + assert_equal(["line", 23, :test_event, TestSetTraceFunc], events.shift) # if b == 3 - assert_equal(["c-call", 15, :==, Fixnum], + assert_equal(["c-call", 23, :==, Fixnum], events.shift) # b == 3 - assert_equal(["c-return", 15, :==, Fixnum], + assert_equal(["c-return", 23, :==, Fixnum], events.shift) # b == 3 - assert_equal(["line", 16, :test_event, TestSetTraceFunc], + assert_equal(["line", 24, :test_event, TestSetTraceFunc], events.shift) # case b - assert_equal(["line", 17, :test_event, TestSetTraceFunc], + assert_equal(["line", 25, :test_event, TestSetTraceFunc], events.shift) # when 2 - assert_equal(["c-call", 17, :===, Kernel], + assert_equal(["c-call", 25, :===, Kernel], events.shift) # when 2 - assert_equal(["c-call", 17, :==, Fixnum], + assert_equal(["c-call", 25, :==, Fixnum], events.shift) # when 2 - assert_equal(["c-return", 17, :==, Fixnum], + assert_equal(["c-return", 25, :==, Fixnum], events.shift) # when 2 - assert_equal(["c-return", 17, :===, Kernel], + assert_equal(["c-return", 25, :===, Kernel], events.shift) # when 2 - assert_equal(["line", 19, :test_event, TestSetTraceFunc], + assert_equal(["line", 27, :test_event, TestSetTraceFunc], events.shift) # when 3 - assert_equal(["c-call", 19, :===, Kernel], + assert_equal(["c-call", 27, :===, Kernel], events.shift) # when 3 - assert_equal(["c-return", 19, :===, Kernel], + assert_equal(["c-return", 27, :===, Kernel], events.shift) # when 3 - assert_equal(["line", 20, :test_event, TestSetTraceFunc], + assert_equal(["line", 28, :test_event, TestSetTraceFunc], events.shift) # c = "b == 3" - assert_equal(["line", 23, :test_event, TestSetTraceFunc], + assert_equal(["line", 31, :test_event, TestSetTraceFunc], events.shift) # begin - assert_equal(["line", 24, :test_event, TestSetTraceFunc], + assert_equal(["line", 32, :test_event, TestSetTraceFunc], events.shift) # raise "error" - assert_equal(["c-call", 24, :raise, Kernel], + assert_equal(["c-call", 32, :raise, Kernel], events.shift) # raise "error" - assert_equal(["c-call", 24, :new, Class], + assert_equal(["c-call", 32, :new, Class], events.shift) # raise "error" - assert_equal(["c-call", 24, :initialize, Exception], + assert_equal(["c-call", 32, :initialize, Exception], events.shift) # raise "error" - assert_equal(["c-return", 24, :initialize, Exception], + assert_equal(["c-return", 32, :initialize, Exception], events.shift) # raise "error" - assert_equal(["c-return", 24, :new, Class], + assert_equal(["c-return", 32, :new, Class], events.shift) # raise "error" - assert_equal(["c-call", 24, :backtrace, Exception], + assert_equal(["c-call", 32, :backtrace, Exception], events.shift) # raise "error" - assert_equal(["c-return", 24, :backtrace, Exception], + assert_equal(["c-return", 32, :backtrace, Exception], events.shift) # raise "error" - assert_equal(["c-call", 24, :set_backtrace, Exception], + assert_equal(["c-call", 32, :set_backtrace, Exception], events.shift) # raise "error" - assert_equal(["c-return", 24, :set_backtrace, Exception], + assert_equal(["c-return", 32, :set_backtrace, Exception], events.shift) # raise "error" - assert_equal(["raise", 24, :test_event, TestSetTraceFunc], + assert_equal(["raise", 32, :test_event, TestSetTraceFunc], events.shift) # raise "error" - assert_equal(["c-return", 24, :raise, Kernel], + assert_equal(["c-return", 32, :raise, Kernel], events.shift) # raise "error" - assert_equal(["line", 27, :test_event, TestSetTraceFunc], + assert_equal(["line", 35, :test_event, TestSetTraceFunc], events.shift) # eval(<<EOF) - assert_equal(["c-call", 27, :eval, Kernel], + assert_equal(["c-call", 35, :eval, Kernel], events.shift) # eval(<<EOF) assert_equal(["line", 1, :test_event, TestSetTraceFunc], events.shift) # class Foo @@ -111,12 +119,19 @@ class TestSetTraceFunc < Test::Unit::TestCase events.shift) # class Foo assert_equal(["end", 1, :test_event, TestSetTraceFunc], events.shift) # class Foo - assert_equal(["c-return", 27, :eval, Kernel], + assert_equal(["c-return", 35, :eval, Kernel], events.shift) # eval(<<EOF) - assert_equal(["line", 28, :test_event, TestSetTraceFunc], + assert_equal(["line", 36, :test_event, TestSetTraceFunc], events.shift) # set_trace_func nil - assert_equal(["c-call", 28, :set_trace_func, Kernel], + assert_equal(["c-call", 36, :set_trace_func, Kernel], events.shift) # set_trace_func nil assert_equal([], events) + + events = bar + set_trace_func(nil) + assert_equal(["return", 7, :bar, TestSetTraceFunc], events.shift) + assert_equal(["line", 131, :test_event, TestSetTraceFunc], events.shift) + assert_equal(["c-call", 131, :set_trace_func, Kernel], events.shift) + assert_equal([], events) end end |