aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb33
1 files changed, 18 insertions, 15 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 57a7c7c9a4..41d3640105 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -740,12 +740,14 @@ class TestIO < Test::Unit::TestCase
end
def safe_4
- Thread.new do
- Timeout.timeout(10) do
- $SAFE = 4
- yield
- end
- end.join
+ t = Thread.new do
+ $SAFE = 4
+ yield
+ end
+ unless t.join(10)
+ t.kill
+ flunk("timeout in safe_4")
+ end
end
def pipe(wp, rp)
@@ -1461,15 +1463,16 @@ End
def test_print_separators
$, = ':'
$\ = "\n"
- r, w = IO.pipe
- w.print('a')
- w.print('a','b','c')
- w.close
- assert_equal("a\n", r.gets)
- assert_equal("a:b:c\n", r.gets)
- assert_nil r.gets
- r.close
-
+ pipe(proc do |w|
+ w.print('a')
+ w.print('a','b','c')
+ w.close
+ end, proc do |r|
+ assert_equal("a\n", r.gets)
+ assert_equal("a:b:c\n", r.gets)
+ assert_nil r.gets
+ r.close
+ end)
ensure
$, = nil
$\ = nil