From 522c538e93cfdb55ea2848d1029f5bca99e403da Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 25 Dec 2010 05:27:12 +0000 Subject: * 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/trunk@30349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io_m17n.rb | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'test/ruby/test_io_m17n.rb') diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 0ae8c793b0..f9fb3e0c5b 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| @@ -125,6 +145,16 @@ EOT end 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| @@ -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| -- cgit v1.2.3