diff options
Diffstat (limited to 'test/io/wait/test_io_wait.rb')
-rw-r--r-- | test/io/wait/test_io_wait.rb | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb index 6b4722e1be..cbc01f9622 100644 --- a/test/io/wait/test_io_wait.rb +++ b/test/io/wait/test_io_wait.rb @@ -3,10 +3,9 @@ require 'test/unit' require 'timeout' require 'socket' -begin - require 'io/wait' -rescue LoadError -end + +# For `IO#ready?` and `IO#nread`: +require 'io/wait' class TestIOWait < Test::Unit::TestCase @@ -37,6 +36,7 @@ class TestIOWait < Test::Unit::TestCase end def test_ready? + omit 'unstable on MinGW' if /mingw/ =~ RUBY_PLATFORM assert_not_predicate @r, :ready?, "shouldn't ready, but ready" @w.syswrite "." sleep 0.1 @@ -50,6 +50,7 @@ class TestIOWait < Test::Unit::TestCase end def test_wait + omit 'unstable on MinGW' if /mingw/ =~ RUBY_PLATFORM assert_nil @r.wait(0) @w.syswrite "." sleep 0.1 @@ -161,6 +162,34 @@ class TestIOWait < Test::Unit::TestCase assert_equal @w, @w.wait(0.01, :read_write) end + def test_wait_mask_writable + omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) + assert_equal IO::WRITABLE, @w.wait(IO::WRITABLE, 0) + end + + def test_wait_mask_readable + omit("Missing IO::READABLE!") unless IO.const_defined?(:READABLE) + @w.write("Hello World\n" * 3) + assert_equal IO::READABLE, @r.wait(IO::READABLE, 0) + + @r.gets + assert_equal IO::READABLE, @r.wait(IO::READABLE, 0) + end + + def test_wait_mask_zero + omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) + assert_raise(ArgumentError) do + @w.wait(0, 0) + end + end + + def test_wait_mask_negative + omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) + assert_raise(ArgumentError) do + @w.wait(-6, 0) + end + end + private def fill_pipe |