From 0fe40d4bb87f475e8100771856b8a046e7c17265 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 6 Oct 2016 03:53:34 +0000 Subject: test_io.rb: split test_gets_rs * test/ruby/test_io.rb (test_gets_rs): split for each record separators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 99ccf7e9d6..c188f2cda3 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -146,7 +146,19 @@ class TestIO < Test::Unit::TestCase end def test_gets_rs - # default_rs + rs = ":" + pipe(proc do |w| + w.print "aaa:bbb" + w.close + end, proc do |r| + assert_equal "aaa:", r.gets(rs) + assert_equal "bbb", r.gets(rs) + assert_nil r.gets(rs) + r.close + end) + end + + def test_gets_default_rs pipe(proc do |w| w.print "aaa\nbbb\n" w.close @@ -156,8 +168,9 @@ class TestIO < Test::Unit::TestCase assert_nil r.gets r.close end) + end - # nil + def test_gets_rs_nil pipe(proc do |w| w.print "a\n\nb\n\n" w.close @@ -166,8 +179,9 @@ class TestIO < Test::Unit::TestCase assert_nil r.gets("") r.close end) + end - # "\377" + def test_gets_rs_377 pipe(proc do |w| w.print "\377xyz" w.close @@ -176,8 +190,9 @@ class TestIO < Test::Unit::TestCase assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]") r.close end) + end - # "" + def test_gets_paragraph pipe(proc do |w| w.print "a\n\nb\n\n" w.close -- cgit v1.2.3