summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-16 06:30:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-16 06:30:14 +0000
commit3143c6d3819e0bef9c5c4170f9f2e4f5d2adbbb0 (patch)
tree055676340401d9c51c7f9bf7247892f62d571d17 /test
parent81704536a4f0a0512862c3af8e948aea2ed30e77 (diff)
merges r30349 from trunk into ruby_1_9_2.
-- * io.c (rb_io_extract_encoding_option): accept Encoding object as encoding: optional argument. [ruby-dev:42884] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io_m17n.rb46
1 files changed, 43 insertions, 3 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 421f36d6e9..6f3a496761 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -114,7 +114,27 @@ EOT
}
end
- def test_open_r_enc_in_opt2
+ def test_open_r_encname_in_opt
+ with_tmpdir {
+ generate_file('tmp', "")
+ open("tmp", "r", encoding: Encoding::EUC_JP) {|f|
+ assert_equal(Encoding::EUC_JP, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ }
+ end
+
+ def test_open_r_ext_enc_in_opt
+ with_tmpdir {
+ generate_file('tmp', "")
+ open("tmp", "r", external_encoding: Encoding::EUC_JP) {|f|
+ assert_equal(Encoding::EUC_JP, f.external_encoding)
+ assert_equal(nil, f.internal_encoding)
+ }
+ }
+ end
+
+ def test_open_r_ext_encname_in_opt
with_tmpdir {
generate_file('tmp', "")
open("tmp", "r", external_encoding: "euc-jp") {|f|
@@ -127,6 +147,16 @@ EOT
def test_open_r_enc_enc
with_tmpdir {
generate_file('tmp', "")
+ open("tmp", "r", external_encoding: Encoding::EUC_JP, internal_encoding: Encoding::UTF_8) {|f|
+ assert_equal(Encoding::EUC_JP, f.external_encoding)
+ assert_equal(Encoding::UTF_8, f.internal_encoding)
+ }
+ }
+ end
+
+ def test_open_r_encname_encname
+ with_tmpdir {
+ generate_file('tmp', "")
open("tmp", "r:euc-jp:utf-8") {|f|
assert_equal(Encoding::EUC_JP, f.external_encoding)
assert_equal(Encoding::UTF_8, f.internal_encoding)
@@ -134,7 +164,7 @@ EOT
}
end
- def test_open_r_enc_enc_in_opt
+ def test_open_r_encname_encname_in_opt
with_tmpdir {
generate_file('tmp', "")
open("tmp", "r", encoding: "euc-jp:utf-8") {|f|
@@ -144,7 +174,17 @@ EOT
}
end
- def test_open_r_enc_enc_in_opt2
+ def test_open_r_enc_enc_in_opt
+ with_tmpdir {
+ generate_file('tmp', "")
+ open("tmp", "r", external_encoding: Encoding::EUC_JP, internal_encoding: Encoding::UTF_8) {|f|
+ assert_equal(Encoding::EUC_JP, f.external_encoding)
+ assert_equal(Encoding::UTF_8, f.internal_encoding)
+ }
+ }
+ end
+
+ def test_open_r_encname_encname_in_opt
with_tmpdir {
generate_file('tmp', "")
open("tmp", "r", external_encoding: "euc-jp", internal_encoding: "utf-8") {|f|