From 45501becfbae97316409d9d1d4d8115936b0a365 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 10 Feb 2012 18:19:57 +0000 Subject: merge revision(s) 33152,33649: * test/ruby/test_io_m17n.rb (TestIO_M17N#test_{default_mode_on_dosish, default_mode_on_unix,text_mode,binary_mode}): sorry for wrong test committed in r33144. I'd misunderstood the spec of ruby's universal newline. * test/ruby/test_io_m17n.rb (TestIO_M17N#test_default_stdout_stderr_mode): new test for r33627-33629. see [backport #5565] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io_m17n.rb | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 01dca47f7f..ecf34c793f 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -2072,29 +2072,49 @@ EOT def test_default_mode_on_dosish with_tmpdir { - open("a", "w") {|f| f.puts} + open("a", "w") {|f| f.write "\n"} assert_equal("\r\n", IO.binread("a")) } end if /mswin|mingw/ =~ RUBY_PLATFORM def test_default_mode_on_unix with_tmpdir { - open("a", "w") {|f| f.puts} + open("a", "w") {|f| f.write "\n"} assert_equal("\n", IO.binread("a")) } end unless /mswin|mingw/ =~ RUBY_PLATFORM def test_text_mode with_tmpdir { - open("a", "wt") {|f| f.puts} - assert_equal("\r\n", IO.binread("a")) + open("a", "wb") {|f| f.write "\r\n"} + assert_equal("\n", open("a", "rt"){|f| f.read}) } end def test_binary_mode with_tmpdir { - open("a", "wb") {|f| f.puts} - assert_equal("\n", IO.binread("a")) + open("a", "wb") {|f| f.write "\r\n"} + assert_equal("\r\n", open("a", "rb"){|f| f.read}) } end + + def test_default_stdout_stderr_mode + with_pipe do |in_r, in_w| + with_pipe do |out_r, out_w| + pid = Process.spawn({}, EnvUtil.rubybin, in: in_r, out: out_w, err: out_w) + in_r.close + out_w.close + in_w.write <<-EOS + STDOUT.puts "abc" + STDOUT.flush + STDERR.puts "def" + STDERR.flush + EOS + in_w.close + Process.wait pid + assert_equal "abc\r\ndef\r\n", out_r.binmode.read + out_r.close + end + end + end if /mswin|mingw/ =~ RUBY_PLATFORM end -- cgit v1.2.3