From 12f2f7371f2dcf9c8da2a96fa251d1af2a7e977e Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 30 Nov 2012 17:00:30 +0000 Subject: [EXPERIMENTAL] * iseq.c: add following two methods. * ISeq#line_trace_all returns all line traces (line numbers) * ISeq#line_trace_specify(pos, set) set `pos'th line event to specified_line event (if set is true). These features are introduced for debuggers (mainly to make breakpoint). * iseq.h: add decl. of C APIs. * test/ruby/test_iseq.rb: add tests. * vm_trace.c: add `specified_line' event. * include/ruby/ruby.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_iseq.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/ruby/test_iseq.rb') diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index ad5391383e..ac140aabde 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -25,4 +25,28 @@ class TestISeq < Test::Unit::TestCase ensure Encoding.default_internal = enc end + + def test_line_trace + iseq = ISeq.compile \ + %q{ a = 1 + b = 2 + c = 3 + # d = 4 + e = 5 + # f = 6 + g = 7 + + } + assert_equal([1, 2, 3, 5, 7], iseq.line_trace_all) + iseq.line_trace_specify(1, true) # line 2 + iseq.line_trace_specify(3, true) # line 5 + + result = [] + TracePoint.new(:specified_line){|tp| + result << tp.lineno + }.enable{ + iseq.eval + } + assert_equal([2, 5], result) + end end -- cgit v1.2.3