diff options
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/envutil.rb | 26 | ||||
-rw-r--r-- | test/ruby/test_continuation.rb | 15 |
2 files changed, 41 insertions, 0 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 4d0ff6b6a2..35aad6d3bc 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -71,3 +71,29 @@ module EnvUtil end module_function :rubyexec end + +module Test + module Unit + module Assertions + public + def assert_normal_exit(testsrc, message = '') + IO.popen([EnvUtil.rubybin, '-W0'], 'w') {|io| + io.write testsrc + } + status = $? + faildesc = nil + if status.signaled? + signo = status.termsig + signame = Signal.list.invert[signo] + sigdesc = "signal #{signo}" + if signame + sigdesc = "SIG#{signame} (#{sigdesc})" + end + full_message = build_message(message, "killed by ?", sigdesc) + end + assert_block(full_message) { !status.signaled? } + end + end + end +end + diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb index 0313d71249..2725996504 100644 --- a/test/ruby/test_continuation.rb +++ b/test/ruby/test_continuation.rb @@ -1,6 +1,7 @@ require 'test/unit' require 'continuation' require 'fiber' +require_relative 'envutil' class TestContinuation < Test::Unit::TestCase def test_create @@ -50,5 +51,19 @@ class TestContinuation < Test::Unit::TestCase c.call } end + + def test_sort + assert_normal_exit(<<-'End') + require 'continuation' + n = 1000 + ary = (1..100).to_a + ary.sort! {|a,b| + callcc {|k| $k = k } if !defined? $k + a <=> b + } + n -= 1 + $k.call if 0 < n + End + end end |