Project

General

Profile

Feature #4347 ยป test_continuation_tracing.patch

quix (James M. Lawrence), 01/31/2011 05:32 AM

View differences:

test/ruby/test_continuation.rb
77 77
    }, '[ruby-dev:34802]'
78 78
  end
79 79

  
80
  def tracing_with_set_trace_func
81
    cont = nil
82
    func = lambda do |*args|
83
      @memo += 1
84
      cont.call(nil)
85
    end
86
    cont = callcc { |cc| cc }
87
    if cont
88
      set_trace_func(func)
89
    else
90
      set_trace_func(nil)
91
    end
92
  end
93

  
94
  def test_tracing_with_set_trace_func
95
    @memo = 0
96
    tracing_with_set_trace_func
97
    tracing_with_set_trace_func
98
    tracing_with_set_trace_func
99
    assert_equal 3, @memo
100
  end
101

  
102
  def tracing_with_thread_set_trace_func
103
    cont = nil
104
    func = lambda do |*args|
105
      @memo += 1
106
      cont.call(nil)
107
    end
108
    cont = callcc { |cc| cc }
109
    if cont
110
      Thread.current.set_trace_func(func)
111
    else
112
      Thread.current.set_trace_func(nil)
113
    end
114
  end
115

  
116
  def test_tracing_with_thread_set_trace_func
117
    @memo = 0
118
    tracing_with_thread_set_trace_func
119
    tracing_with_thread_set_trace_func
120
    tracing_with_thread_set_trace_func
121
    assert_equal 3, @memo
122
  end
80 123
end
81 124