diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-23 02:23:42 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-23 02:23:42 +0000 |
commit | 860c2331039537c4d0c5c8c92ae1e89395f0edcc (patch) | |
tree | 46aca87ad648da3ee8f5caf5a433c0e3193f74fc /test | |
parent | 3721df734c9ad1be0bbd64321329c1af405b289b (diff) | |
download | ruby-860c2331039537c4d0c5c8c92ae1e89395f0edcc.tar.gz |
* io.c (rb_io_extract_modeenc): check :textmode and :binmode in option
hash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 9fb3c63e2a..59a691cbd6 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -979,11 +979,18 @@ EOT } end + def test_both_textmode_binmode + assert_raise(ArgumentError) { open("not-exist", "r", :textmode=>true, :binmode=>true) } + end + def test_textmode_decode_universal_newline_read with_tmpdir { generate_file("t.crlf", "a\r\nb\r\nc\r\n") assert_equal("a\nb\nc\n", File.read("t.crlf", mode:"rt:euc-jp:utf-8")) assert_equal("a\nb\nc\n", File.read("t.crlf", mode:"rt")) + 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) } generate_file("t.cr", "a\rb\rc\r") assert_equal("a\nb\nc\n", File.read("t.cr", mode:"rt:euc-jp:utf-8")) @@ -1105,6 +1112,9 @@ EOT open("t.txt", "rb") {|f| assert_equal(src, f.read) } + open("t.txt", "r", :binmode=>true) {|f| + assert_equal(src, f.read) + } if File::BINARY == 0 open("t.txt", "r") {|f| assert_equal(src, f.read) |