diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2022-06-25 19:21:37 +1200 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-06-25 16:21:54 +0900 |
commit | f9c8d8088378981385f6acd18d2fe9fedcd7ab85 (patch) | |
tree | fc9696553ed0befe992447813a4e219c2795c211 /test/io | |
parent | 2b4a1ad58429c69483160ca86eaaeb544218818e (diff) | |
download | ruby-f9c8d8088378981385f6acd18d2fe9fedcd7ab85.tar.gz |
[ruby/io-wait] Don't add `IO#wait*` methods when `RUBY_IO_WAIT_METHODS` is defined by Ruby. (https://github.com/ruby/io-wait/pull/19)
* Fix return value compatibility with Ruby 2.x.
* Don't add `IO#wait*` methods in Ruby 3.2+.
https://github.com/ruby/io-wait/commit/54c504d089
Diffstat (limited to 'test/io')
-rw-r--r-- | test/io/wait/test_io_wait.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb index 6b4722e1be..5d0f0bfd34 100644 --- a/test/io/wait/test_io_wait.rb +++ b/test/io/wait/test_io_wait.rb @@ -161,6 +161,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_raises(ArgumentError) do + @w.wait(0, 0) + end + end + + def test_wait_mask_negative + omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) + assert_raises(ArgumentError) do + @w.wait(-6, 0) + end + end + private def fill_pipe |