summaryrefslogtreecommitdiff
path: root/test/-ext-
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-04 09:50:27 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-04 09:50:27 +0000
commit2a989121db8f80aceeadb5d403af79d4b30e1bb8 (patch)
treef9e7ac9a210649fcd0cb7407453d94964796bc9e /test/-ext-
parent8a98c57ff064ac8f1555be414e28df418685ca30 (diff)
* ext/-test-/wait_for_single_fd: New. for testing
rb_wait_for_single_fd() internal function. The patch was written by Eric Wong. [ruby-core:35991] * test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-')
-rw-r--r--test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb b/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
new file mode 100644
index 0000000000..76ef68002a
--- /dev/null
+++ b/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
@@ -0,0 +1,32 @@
+require 'test/unit'
+
+class TestWaitForSingleFD < Test::Unit::TestCase
+ require '-test-/wait_for_single_fd/wait_for_single_fd'
+
+ def with_pipe
+ r, w = IO.pipe
+ begin
+ yield r, w
+ ensure
+ r.close unless r.closed?
+ w.close unless w.closed?
+ end
+ end
+
+ def test_wait_for_valid_fd
+ with_pipe do |r,w|
+ rc = IO.wait_for_single_fd(w.fileno, RB_WAITFD_OUT, nil)
+ assert_equal RB_WAITFD_OUT, rc
+ end
+ end
+
+ def test_wait_for_invalid_fd
+ with_pipe do |r,w|
+ wfd = w.fileno
+ w.close
+ assert_raises(Errno::EBADF) do
+ IO.wait_for_single_fd(wfd, RB_WAITFD_OUT, nil)
+ end
+ end
+ end
+end