From 3a7daf882bf737c2e9a6c7a9aece2424cb3f4547 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 22 Dec 2008 12:27:26 +0000 Subject: * 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 --- test/ruby/test_io.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/ruby/test_io.rb') 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 -- cgit v1.2.3