summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_settracefunc.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
new file mode 100644
index 000000000..515453245
--- /dev/null
+++ b/test/ruby/test_settracefunc.rb
@@ -0,0 +1,26 @@
+require 'test/unit'
+
+class TestSetTraceFunc < Test::Unit::TestCase
+ def foo; end
+
+ def test_event
+ events = []
+ set_trace_func(Proc.new { |event, file, lineno|
+ events << [event, lineno]
+ })
+ a = 1
+ foo
+ a
+ set_trace_func nil
+
+ assert_equal(["line", 11], events.shift) # line "a = 1"
+ assert_equal(["line", 12], events.shift) # line "foo"
+ assert_equal(["call", 4], events.shift) # call foo
+ event, lineno = events.shift # return
+ assert_equal("return", event)
+ assert_equal(4, lineno) # [history] it could not be expected in 1.8
+ assert_equal(["line", 13], events.shift) # line "a"
+ assert_equal(["line", 14], events.shift) # line "set_trace_func nil"
+ assert_equal(["c-call", 14], events.shift) # c-call set_trace_func
+ end
+end