diff --git a/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb b/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb index 677c013d4b..777e9d14dd 100644 --- a/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb +++ b/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb @@ -4,18 +4,8 @@ require 'test/unit' class TestWaitForSingleFD < Test::Unit::TestCase require '-test-/wait_for_single_fd' - def with_pipe - r, w = IO.pipe - begin - yield r, w - ensure - r.close unless r.closed? - w.close unless w.closed? - end - end - def test_wait_for_valid_fd - with_pipe do |r,w| + IO.pipe do |r,w| rc = IO.wait_for_single_fd(w.fileno, RB_WAITFD_OUT, nil) assert_equal RB_WAITFD_OUT, rc end @@ -35,7 +25,7 @@ class TestWaitForSingleFD < Test::Unit::TestCase ver = $1.to_r skip 'FreeBSD <= 8.2' if ver <= 8.2r end - with_pipe do |r,w| + IO.pipe do |r,w| wfd = w.fileno w.close assert_raise(Errno::EBADF) do @@ -45,7 +35,7 @@ class TestWaitForSingleFD < Test::Unit::TestCase end def test_wait_for_closed_pipe - with_pipe do |r,w| + IO.pipe do |r,w| w.close rc = IO.wait_for_single_fd(r.fileno, RB_WAITFD_IN, nil) assert_equal RB_WAITFD_IN, rc