2004-11-29 00:00:46 -05:00
|
|
|
require 'test/unit'
|
2004-11-29 01:22:42 -05:00
|
|
|
begin
|
|
|
|
require 'io/nonblock'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2004-11-29 00:00:46 -05:00
|
|
|
|
|
|
|
class TestIONonblock < Test::Unit::TestCase
|
|
|
|
def test_flush # [ruby-dev:24985]
|
2006-12-31 10:02:22 -05:00
|
|
|
flunk "YARV doesn't support io/nonblock"
|
2004-11-29 00:00:46 -05:00
|
|
|
r,w = IO.pipe
|
|
|
|
w.nonblock = true
|
|
|
|
w.sync = false
|
|
|
|
w << "b"
|
|
|
|
w.flush
|
|
|
|
w << "a" * 4096
|
|
|
|
Thread.new {
|
|
|
|
Thread.pass
|
|
|
|
w.close
|
|
|
|
}
|
2004-11-29 00:21:47 -05:00
|
|
|
result = ""
|
|
|
|
t = Thread.new {
|
|
|
|
while (Thread.pass; s = r.read(4096))
|
|
|
|
result << s
|
|
|
|
end
|
2004-11-29 00:00:46 -05:00
|
|
|
}
|
|
|
|
assert_raise(IOError) {w.flush}
|
2004-12-07 13:26:12 -05:00
|
|
|
assert_nothing_raised {t.join}
|
|
|
|
assert_equal(4097, result.size)
|
2004-11-29 00:00:46 -05:00
|
|
|
end
|
2004-11-29 01:22:42 -05:00
|
|
|
end if IO.method_defined?(:nonblock)
|