1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/envutil.rb (Test::Unit::Assertions#assert_normal_exit):

new method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-05-03 11:57:55 +00:00
parent 724d6ffd54
commit 091333f9ea
3 changed files with 46 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sat May 3 20:57:06 2008 Tanaka Akira <akr@fsij.org>
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_normal_exit):
new method.
Sat May 3 18:10:54 2008 Tanaka Akira <akr@fsij.org>
* time.c (time_timespec): raise TypeError for nil and other objects

View file

@ -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

View file

@ -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