summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-07 08:47:09 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-07 08:47:09 +0000
commit6f8fe02f967b5c6024df40eba5ef98dcb076381f (patch)
treed1319db925cc75b7e9d11ee7b4b852f10c52a92d /test
parent3c887f64a4ac54a3f931b8ef1030470b23b52224 (diff)
* eval.c (rb_call0): "return" event hook should be always executed
if event_hooks is set. fixed: [ruby-core:04662] (backported from HEAD) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_settracefunc.rb94
1 files changed, 55 insertions, 39 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index aa21812..39e1b03 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,20 @@ 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(["line", 11, :bar, TestSetTraceFunc], events.shift)
+ 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