summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 08:47:26 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 08:47:26 +0000
commit4834aa5307d8c4750b7598b6b2ef8728d01d98b4 (patch)
tree3d4339c6e04d7cd902072637e9d7fc25a60e5573 /test/ruby
parentce573f3166d8b80d6a0b9c6c027b0c5e10f05c4b (diff)
* io.c (rb_io_ext_int_to_encs): ignore internal encoding if external
encoding is ASCII-8BIT. [Bug #8342] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io_m17n.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index ec2086186c..ac3b8eaa1e 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -105,6 +105,42 @@ EOT
}
end
+ def test_open_r_ascii8bit
+ with_tmpdir {
+ generate_file('tmp', "")
+ EnvUtil.with_default_external(Encoding::ASCII_8BIT) do
+ EnvUtil.with_default_internal(Encoding::UTF_8) do
+ open("tmp", "r") {|f|
+ assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ open("tmp", "r:ascii-8bit") {|f|
+ assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ open("tmp", "r:ascii-8bit:utf-16") {|f|
+ assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ end
+ EnvUtil.with_default_internal(nil) do
+ open("tmp", "r") {|f|
+ assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ open("tmp", "r:ascii-8bit") {|f|
+ assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ open("tmp", "r:ascii-8bit:utf-16") {|f|
+ assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ end
+ end
+ }
+ end
+
def test_open_r_enc_in_opt
with_tmpdir {
generate_file('tmp', "")