[前][次][番号順一覧][スレッド一覧]

ruby-changes:41566

From: nobu <ko1@a...>
Date: Sun, 24 Jan 2016 14:30:08 +0900 (JST)
Subject: [ruby-changes:41566] nobu:r53640 (trunk): test_io_wait.rb: wait_readable

nobu	2016-01-24 14:30:54 +0900 (Sun, 24 Jan 2016)

  New Revision: 53640

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53640

  Log:
    test_io_wait.rb: wait_readable
    
    * test/io/wait/test_io_wait.rb: add tests for IO#wait_readable,
      same as IO#wait.

  Modified files:
    trunk/test/io/wait/test_io_wait.rb
Index: test/io/wait/test_io_wait.rb
===================================================================
--- test/io/wait/test_io_wait.rb	(revision 53639)
+++ test/io/wait/test_io_wait.rb	(revision 53640)
@@ -80,6 +80,37 @@ class TestIOWait < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/io/wait/test_io_wait.rb#L80
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]