summaryrefslogtreecommitdiff
path: root/test/ruby/test_continuation.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_continuation.rb')
-rw-r--r--test/ruby/test_continuation.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb
index 52d8de482c..612dbf28c9 100644
--- a/test/ruby/test_continuation.rb
+++ b/test/ruby/test_continuation.rb
@@ -1,9 +1,13 @@
+# frozen_string_literal: false
require 'test/unit'
-require 'continuation'
+EnvUtil.suppress_warning {require 'continuation'}
require 'fiber'
-require_relative 'envutil'
class TestContinuation < Test::Unit::TestCase
+ def setup
+ omit 'requires callcc support' unless respond_to?(:callcc)
+ end
+
def test_create
assert_equal(:ok, callcc{:ok})
assert_equal(:ok, callcc{|c| c.call :ok})
@@ -37,9 +41,11 @@ class TestContinuation < Test::Unit::TestCase
def test_error
cont = callcc{|c| c}
- assert_raise(RuntimeError){
- Thread.new{cont.call}.join
- }
+ Thread.new{
+ assert_raise(RuntimeError){
+ cont.call
+ }
+ }.join
assert_raise(LocalJumpError){
callcc
}
@@ -86,11 +92,16 @@ class TestContinuation < Test::Unit::TestCase
@memo += 1
c = cont
cont = nil
- c.call(nil)
+ begin
+ c.call(nil)
+ rescue RuntimeError
+ set_trace_func(nil)
+ end
end
end
end
cont = callcc { |cc| cc }
+
if cont
set_trace_func(func)
else
@@ -98,12 +109,12 @@ class TestContinuation < Test::Unit::TestCase
end
end
- def test_tracing_with_set_trace_func
+ 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
+ assert_equal 0, @memo
end
def tracing_with_thread_set_trace_func
@@ -113,7 +124,11 @@ class TestContinuation < Test::Unit::TestCase
@memo += 1
c = cont
cont = nil
- c.call(nil)
+ begin
+ c.call(nil)
+ rescue RuntimeError
+ Thread.current.set_trace_func(nil)
+ end
end
end
cont = callcc { |cc| cc }
@@ -132,4 +147,3 @@ class TestContinuation < Test::Unit::TestCase
assert_equal 3, @memo
end
end
-