aboutsummaryrefslogtreecommitdiffstats
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.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index ecf34c793f..18f84c6253 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -2117,4 +2117,61 @@ EOT
end
end
end if /mswin|mingw/ =~ RUBY_PLATFORM
+
+ def test_cr_decorator_on_stdout
+ 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)
+ in_r.close
+ out_w.close
+ in_w.write <<-EOS
+ STDOUT.set_encoding('locale', nil, newline: :cr)
+ STDOUT.puts "abc"
+ STDOUT.flush
+ EOS
+ in_w.close
+ Process.wait pid
+ assert_equal "abc\r", out_r.binmode.read
+ out_r.close
+ end
+ end
+ end
+
+ def test_lf_decorator_on_stdout
+ 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)
+ in_r.close
+ out_w.close
+ in_w.write <<-EOS
+ STDOUT.set_encoding('locale', nil, newline: :lf)
+ STDOUT.puts "abc"
+ STDOUT.flush
+ EOS
+ in_w.close
+ Process.wait pid
+ assert_equal "abc\n", out_r.binmode.read
+ out_r.close
+ end
+ end
+ end
+
+ def test_crlf_decorator_on_stdout
+ 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)
+ in_r.close
+ out_w.close
+ in_w.write <<-EOS
+ STDOUT.set_encoding('locale', nil, newline: :crlf)
+ STDOUT.puts "abc"
+ STDOUT.flush
+ EOS
+ in_w.close
+ Process.wait pid
+ assert_equal "abc\r\n", out_r.binmode.read
+ out_r.close
+ end
+ end
+ end
end