~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/ruby/test_continuation.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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