diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-21 12:12:53 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-21 12:12:53 +0000 |
commit | 1d9cac36ea4d84a6e3242c7b8a30d05b6df64145 (patch) | |
tree | ebabedc68d72fac5c489f8c2b815b7d45ea812e3 /test | |
parent | f0353afdc1f94393338ac07ed2dc02c71ed951c5 (diff) |
* backport r32597 from trunk.
* thread.c (set_trace_func, thread_set_trace_func_m): reset tracing
state when set_trace_func hook is removed. This is workaround patch
to force to reset tracing state that is broken by continuation call.
a patch from James M. Lawrence. [Feature #4347] [ruby-core:34998]
* test/ruby/test_continuation.rb (class TestContinuation): add a test
for above. a patch from James M. Lawrence.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_continuation.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb index c719db8c35..64390d8177 100644 --- a/test/ruby/test_continuation.rb +++ b/test/ruby/test_continuation.rb @@ -77,5 +77,48 @@ class TestContinuation < Test::Unit::TestCase }, '[ruby-dev:34802]' end + def tracing_with_set_trace_func + cont = nil + func = lambda do |*args| + @memo += 1 + cont.call(nil) + end + cont = callcc { |cc| cc } + if cont + set_trace_func(func) + else + set_trace_func(nil) + end + end + + def test_tracing_with_set_trace_func + @memo = 0 + tracing_with_set_trace_func + tracing_with_set_trace_func + tracing_with_set_trace_func + assert_equal 3, @memo + end + + def tracing_with_thread_set_trace_func + cont = nil + func = lambda do |*args| + @memo += 1 + cont.call(nil) + end + cont = callcc { |cc| cc } + if cont + Thread.current.set_trace_func(func) + else + Thread.current.set_trace_func(nil) + end + end + + def test_tracing_with_thread_set_trace_func + @memo = 0 + tracing_with_thread_set_trace_func + tracing_with_thread_set_trace_func + tracing_with_thread_set_trace_func + assert_equal 3, @memo + end end |