From 970ce679ff818f1fee27fd07cb4ed01e9c8cc824 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Wed, 17 Nov 2004 14:49:07 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'ruby_1_8'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_settracefunc.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/ruby/test_settracefunc.rb (limited to 'test/ruby') diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb new file mode 100644 index 0000000000..515453245f --- /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 -- cgit v1.2.3