summaryrefslogtreecommitdiff
path: root/test/ruby/test_io_m17n.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-14 10:53:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-14 10:53:35 +0000
commit57464618abee8c5d35d9a24767cdb62d1459b341 (patch)
treed5459776f9ccdf4059fb720f97823fc7ffca1e7e /test/ruby/test_io_m17n.rb
parentf7ef047f8e3e271e8defa0065959416a188a8fd4 (diff)
io.c: textmode if newline decorator
* io.c (validate_enc_binmode): newline decorator implies text mode now. [ruby-core:80270] [Bug #13350] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io_m17n.rb')
-rw-r--r--test/ruby/test_io_m17n.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 4a7cf338830..ccb124a46b7 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -1608,6 +1608,44 @@ EOT
}
end
+
+ def test_binmode_decode_universal_newline
+ with_tmpdir {
+ generate_file("t.txt", "a\n")
+ assert_raise(ArgumentError) {
+ open("t.txt", "rb", newline: :universal) {}
+ }
+ }
+ end
+
+ def test_default_mode_decode_universal_newline_gets
+ with_tmpdir {
+ generate_file("t.crlf", "a\r\nb\r\nc\r\n")
+ open("t.crlf", "r", newline: :universal) {|f|
+ assert_equal("a\n", f.gets)
+ assert_equal("b\n", f.gets)
+ assert_equal("c\n", f.gets)
+ assert_equal(nil, f.gets)
+ }
+
+ generate_file("t.cr", "a\rb\rc\r")
+ open("t.cr", "r", newline: :universal) {|f|
+ assert_equal("a\n", f.gets)
+ assert_equal("b\n", f.gets)
+ assert_equal("c\n", f.gets)
+ assert_equal(nil, f.gets)
+ }
+
+ generate_file("t.lf", "a\nb\nc\n")
+ open("t.lf", "r", newline: :universal) {|f|
+ assert_equal("a\n", f.gets)
+ assert_equal("b\n", f.gets)
+ assert_equal("c\n", f.gets)
+ assert_equal(nil, f.gets)
+ }
+ }
+ end
+
def test_read_newline_conversion_with_encoding_conversion
with_tmpdir {
generate_file("t.utf8.crlf", "a\r\nb\r\n")