From ea290804891b259cce4a156790ba024c1d52ad27 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 27 Nov 2014 11:06:51 +0000 Subject: * compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449] * test/ruby/test_settracefunc.rb: add and fix tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_settracefunc.rb | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 44a9edee11..637078ae6e 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -506,7 +506,6 @@ class TestSetTraceFunc < Test::Unit::TestCase [:return, 16, "xyzzy", xyzzy.class, :bar, xyzzy, :XYZZY_bar, xyzzy], [:return, 12, "xyzzy", xyzzy.class, :foo, xyzzy, :XYZZY_foo, xyzzy], [:line, 20, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing], - [:line, 20, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing], [:c_call, 20, "xyzzy", Kernel, :raise, self, :outer, :nothing], [:c_call, 20, "xyzzy", Exception, :exception, RuntimeError, :outer, :nothing], [:c_call, 20, "xyzzy", Exception, :initialize, raised_exc, :outer, :nothing], @@ -562,14 +561,18 @@ class TestSetTraceFunc < Test::Unit::TestCase def test_tracepoint events1, answer_events = *trace_by_tracepoint(:line, :class, :end, :call, :return, :c_call, :c_return, :raise) - mesg = events1.map{|e| - if false - p [:event, e[0]] - p [:line_file, e[1], e[2]] - p [:id, e[4]] + ms = [events1, answer_events].map{|evs| + evs.map{|e| + "#{e[0]} - #{e[2]}:#{e[1]} id: #{e[4]}" + } + } + + mesg = ms[0].zip(ms[1]).map{|a, b| + if a != b + "#{a} <-> #{b}" end - "#{e[0]} - #{e[2]}:#{e[1]} id: #{e[4]}" - }.join("\n") + }.compact.join("\n") + answer_events.zip(events1){|answer, event| assert_equal answer, event, mesg } @@ -1294,4 +1297,18 @@ class TestSetTraceFunc < Test::Unit::TestCase } end end + + def test_no_duplicate_line_events + lines = [] + dummy = [] + + TracePoint.new(:line){|tp| + next unless target_thread? + lines << tp.lineno + }.enable{ + dummy << (1) + (2) + dummy << (1) + (2) + } + assert_equal [__LINE__ - 3, __LINE__ - 2], lines, 'Bug #10449' + end end -- cgit v1.2.3