summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-20 17:29:18 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-20 17:29:18 +0000
commitd7bfcb65dbe5fe5907c4e1ffbc59e2049ef90984 (patch)
tree4c2beefe0efaa226f0ee63582ff47949484c6dac /test
parentb16647f8f8bdaf46aed98dc22afdf9329840f19a (diff)
downloadruby-d7bfcb65dbe5fe5907c4e1ffbc59e2049ef90984.tar.gz
ruby-d7bfcb65dbe5fe5907c4e1ffbc59e2049ef90984.tar.xz
ruby-d7bfcb65dbe5fe5907c4e1ffbc59e2049ef90984.zip
* test/ruby/test_io.rb (test_gets_rs): add more tests.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 642c8f443..b256a2730 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2,10 +2,37 @@ require 'test/unit'
class TestIO < Test::Unit::TestCase
def test_gets_rs
+ # default_rs
+ r, w = IO.pipe
+ w.print "aaa\nbbb\n"
+ w.close
+ assert_equal "aaa\n", r.gets
+ assert_equal "bbb\n", r.gets
+ assert_nil r.gets
+ r.close
+
+ # nil
+ r, w = IO.pipe
+ w.print "a\n\nb\n\n"
+ w.close
+ assert_equal "a\n\nb\n\n", r.gets(nil)
+ assert_nil r.gets("")
+ r.close
+
+ # "\377" [ruby-dev:24460]
r, w = IO.pipe
w.print "\377xyz"
w.close
assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]")
r.close
+
+ # "" [ruby-core:03771]
+ r, w = IO.pipe
+ w.print "a\n\nb\n\n"
+ w.close
+ assert_equal "a\n\n", r.gets("")
+ assert_equal "b\n\n", r.gets("")
+ assert_nil r.gets("")
+ r.close
end
end