mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_wait_for_single_fd.rb: remove with_pipe helper
IO.pipe natively accepts a block, nowadays. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
863e24b2b1
commit
b6f9a60586
1 changed files with 3 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue