summaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-22 12:27:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-22 12:27:26 +0000
commitd7055445204327f4bd2a89f73899a86aaaa2cc5e (patch)
tree16383b4b77598d0f449a9617e877ceb90a8e7e74 /test/ruby
parentf22cf014cc4ef0afa35d081ca14c6ef9da9c6c45 (diff)
downloadruby-d7055445204327f4bd2a89f73899a86aaaa2cc5e.tar.gz
ruby-d7055445204327f4bd2a89f73899a86aaaa2cc5e.tar.xz
ruby-d7055445204327f4bd2a89f73899a86aaaa2cc5e.zip
* io.c (rb_io_s_pipe): IO.pipe can take a block.
(pipe_close): new function. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 78cb425ed..d00c0a3f7 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -22,6 +22,34 @@ class TestIO < Test::Unit::TestCase
IO.instance_methods.index(:"nonblock=")
end
+ def test_pipe
+ r, w = IO.pipe
+ assert_instance_of(IO, r)
+ assert_instance_of(IO, w)
+ w.print "abc"
+ w.close
+ assert_equal("abc", r.read)
+ r.close
+ end
+
+ def test_pipe_block
+ x = nil
+ ret = IO.pipe {|r, w|
+ x = [r,w]
+ assert_instance_of(IO, r)
+ assert_instance_of(IO, w)
+ w.print "abc"
+ w.close
+ assert_equal("abc", r.read)
+ assert(!r.closed?)
+ assert(w.closed?)
+ :foooo
+ }
+ assert_equal(:foooo, ret)
+ assert(x[0].closed?)
+ assert(x[1].closed?)
+ end
+
def test_gets_rs
# default_rs
r, w = IO.pipe