summaryrefslogtreecommitdiff
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
commit3a7daf882bf737c2e9a6c7a9aece2424cb3f4547 (patch)
tree16383b4b77598d0f449a9617e877ceb90a8e7e74 /test/ruby
parentc8cbfe7deba037b72e2a3c8f7dd604731e43de55 (diff)
* io.c (rb_io_s_pipe): IO.pipe can take a block.
(pipe_close): new function. git-svn-id: svn+ssh://ci.ruby-lang.org/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 78cb425ed1..d00c0a3f7c 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