summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-26 15:55:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-26 15:55:21 +0000
commit876146772787599c894369801034f1fed1d16b54 (patch)
tree91f02a41b3b508bfea3bffbe4e27985cac0a75d4 /test/ruby
parent3b937bbdc4abc6ec1d3ec5d6b4e31714e0456e35 (diff)
* io.c (validate_enc_binmode, rb_io_extract_modeenc): set newline
decorator according to open mode. * transcode.c (rb_econv_prepare_options): new function, to prepare econv options with newline flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_econv.rb10
-rw-r--r--test/ruby/test_io_m17n.rb3
2 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index 00682f69cd..765616da3d 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -449,6 +449,16 @@ class TestEncodingConverter < Test::Unit::TestCase
assert_econv("abc\rdef", :finished, 50, ec, "abc\ndef", "")
end
+ def test_no_universal_newline1
+ ec = Encoding::Converter.new("UTF-8", "EUC-JP", universal_newline: false)
+ assert_econv("abc\r\ndef", :finished, 50, ec, "abc\r\ndef", "")
+ end
+
+ def test_no_universal_newline2
+ ec = Encoding::Converter.new("", "", universal_newline: false)
+ assert_econv("abc\r\ndef", :finished, 50, ec, "abc\r\ndef", "")
+ end
+
def test_after_output
ec = Encoding::Converter.new("UTF-8", "EUC-JP")
a = ["", "abc\u{3042}def", ec, nil, 100, :after_output=>true]
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index db1fe0b539..86d45a50ae 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -1349,6 +1349,9 @@ EOT
open("t.crlf", "rt:euc-jp:utf-8") {|f| assert_equal("a\nb\nc\n", f.read) }
open("t.crlf", "rt") {|f| assert_equal("a\nb\nc\n", f.read) }
open("t.crlf", "r", :textmode=>true) {|f| assert_equal("a\nb\nc\n", f.read) }
+ open("t.crlf", "r", textmode: true, universal_newline: false) {|f|
+ assert_equal("a\r\nb\r\nc\r\n", f.read)
+ }
generate_file("t.cr", "a\rb\rc\r")
assert_equal("a\nb\nc\n", File.read("t.cr", mode:"rt:euc-jp:utf-8"))