summaryrefslogtreecommitdiff
path: root/test/io/wait/test_io_wait.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-24 05:30:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-24 05:30:54 +0000
commit5320f8846b207ba45d56f357b17b6e6914c475f7 (patch)
tree283f24e629419d38363a29b4dcdbaa6b331d4f54 /test/io/wait/test_io_wait.rb
parentbe8b517f5288a0d51523e9c8452280af36edcb22 (diff)
test_io_wait.rb: wait_readable
* test/io/wait/test_io_wait.rb: add tests for IO#wait_readable, same as IO#wait. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/io/wait/test_io_wait.rb')
-rw-r--r--test/io/wait/test_io_wait.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb
index 637917d5104..a19d2a1ea9c 100644
--- a/test/io/wait/test_io_wait.rb
+++ b/test/io/wait/test_io_wait.rb
@@ -80,6 +80,37 @@ class TestIOWait < Test::Unit::TestCase
th.join
end
+ def test_wait_readable
+ assert_nil @r.wait_readable(0)
+ @w.syswrite "."
+ sleep 0.1
+ assert_equal @r, @r.wait_readable(0)
+ end
+
+ def test_wait_readable_buffered
+ @w.syswrite ".\n!"
+ assert_equal ".\n", @r.gets
+ assert_equal true, @r.wait_readable(0)
+ end
+
+ def test_wait_readable_forever
+ th = Thread.new { sleep 0.01; @w.syswrite "." }
+ assert_equal @r, @r.wait_readable
+ ensure
+ th.join
+ end
+
+ def test_wait_readable_eof
+ th = Thread.new { sleep 0.01; @w.close }
+ ret = nil
+ assert_nothing_raised(Timeout::Error) do
+ Timeout.timeout(0.1) { ret = @r.wait_readable }
+ end
+ assert_equal @r, ret
+ ensure
+ th.join
+ end
+
def test_wait_writable
assert_equal @w, @w.wait_writable
end