summaryrefslogtreecommitdiff
path: root/test/ruby/test_io_m17n.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_io_m17n.rb')
-rw-r--r--test/ruby/test_io_m17n.rb48
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