diff options
author | luislavena <luislavena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-04 01:10:06 +0000 |
---|---|---|
committer | luislavena <luislavena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-04 01:10:06 +0000 |
commit | f9a6a1dd0c687dfc6e63e5d20bc3812416def301 (patch) | |
tree | 2f77668d636ebbc6fd4deeb05dae91d97f71b38c /test/ruby | |
parent | 4a1cfe70dc31f9be8a12908d85b51297d61b8eae (diff) | |
download | ruby-f9a6a1dd0c687dfc6e63e5d20bc3812416def301.tar.gz |
Introduce NEED_READCONV and NEED_WRITECONV to replace universal newline decorator
Use CRLF only when required to improve file reading and writing under Windows.
Patch by Hiroshi Shirosaki. [ruby-core:40706] [Feature #5562]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 18f84c6253..6f823c85a3 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -2174,4 +2174,52 @@ EOT end end end + + def test_binmode_with_pipe + with_pipe do |r, w| + src = "a\r\nb\r\nc\r\n" + w.binmode.write src + w.close + + assert_equal("a", r.getc) + assert_equal("\n", r.getc) + r.binmode + assert_equal("b", r.getc) + assert_equal("\r", r.getc) + assert_equal("\n", r.getc) + assert_equal("c", r.getc) + assert_equal("\r", r.getc) + assert_equal("\n", r.getc) + assert_equal(nil, r.getc) + r.close + end + end if /mswin|mingw/ =~ RUBY_PLATFORM + + def test_stdin_binmode + with_pipe do |in_r, in_w| + with_pipe do |out_r, out_w| + pid = Process.spawn({}, EnvUtil.rubybin, '-e', <<-'End', in: in_r, out: out_w) + STDOUT.binmode + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + STDIN.binmode + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + STDOUT.write STDIN.getc + End + in_r.close + out_w.close + src = "a\r\nb\r\nc\r\n" + in_w.binmode.write src + in_w.close + Process.wait pid + assert_equal "a\nb\r\nc\r\n", out_r.binmode.read + out_r.close + end + end + end if /mswin|mingw/ =~ RUBY_PLATFORM end |