Project

General

Profile

Bug #10724 » test_for_issue_10724.rb

deivid (David Rodríguez), 01/20/2015 01:22 PM

 
1
require 'test/unit'
2

    
3
class TestMissingReturn < Test::Unit::TestCase
4
  class A
5
    def initialize
6
      loop { return }
7
    end
8
  end
9

    
10
  def test_tp_misses_return_event_when_return_inside_loop_inside_initialize
11
    events = []
12

    
13
    tracepoint = TracePoint.new(:call, :c_call, :c_return, :return) do |tp|
14
      events << [ tp.event, tp.method_id]
15
    end
16

    
17
    tracepoint.enable { A.new }
18

    
19
    expected_events = [ [:c_call, :new],
20
                        [:call, :initialize],
21
                        [:c_call, :loop],
22
                        [:c_return, :loop],
23
                        [:return, :initialize],
24
                        [:c_return, :new]
25
                      ]
26

    
27
    assert_equal expected_events, events
28
  end
29
end