diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 08:24:49 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 08:24:49 +0000 |
commit | 89b4f06a596e993a82630913f085a82265cb499c (patch) | |
tree | 0395f1dbd574c3422177d2fbdc9f045608fb77f4 /test | |
parent | f7bdac01c245ed85e97655bb48f279183bf03557 (diff) | |
download | ruby-89b4f06a596e993a82630913f085a82265cb499c.tar.gz |
* io.c (clear_readconv): extracted from rb_io_fptr_finalize.
(mode_enc): call clear_readconv.
(io_set_encoding): ditto.
(argf_next_argv): ditto.
(io_encoding_set): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 7bcd051c36..e982722cfe 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -552,5 +552,54 @@ EOT } } end + + def test_set_encoding + with_pipe("utf-8:euc-jp") {|r, w| + s = "\u3042".force_encoding("ascii-8bit") + s << "\x82\xa0".force_encoding("ascii-8bit") + w << s + w.close + assert_equal("\xa4\xa2".force_encoding("euc-jp"), r.getc) + r.set_encoding("shift_jis:euc-jp") + assert_equal("\xa4\xa2".force_encoding("euc-jp"), r.getc) + } + end + + def test_set_encoding2 + with_pipe("utf-8:euc-jp") {|r, w| + s = "\u3042".force_encoding("ascii-8bit") + s << "\x82\xa0".force_encoding("ascii-8bit") + w << s + w.close + assert_equal("\xa4\xa2".force_encoding("euc-jp"), r.getc) + r.set_encoding("shift_jis", "euc-jp") + assert_equal("\xa4\xa2".force_encoding("euc-jp"), r.getc) + } + end + + def test_set_encoding_nil + with_pipe("utf-8:euc-jp") {|r, w| + s = "\u3042".force_encoding("ascii-8bit") + s << "\x82\xa0".force_encoding("ascii-8bit") + w << s + w.close + assert_equal("\xa4\xa2".force_encoding("euc-jp"), r.getc) + r.set_encoding(nil) + assert_equal("\x82\xa0".force_encoding(Encoding.default_external), r.read) + } + end + + def test_set_encoding_enc + with_pipe("utf-8:euc-jp") {|r, w| + s = "\u3042".force_encoding("ascii-8bit") + s << "\x82\xa0".force_encoding("ascii-8bit") + w << s + w.close + assert_equal("\xa4\xa2".force_encoding("euc-jp"), r.getc) + r.set_encoding(Encoding::Shift_JIS) + assert_equal("\x82\xa0".force_encoding(Encoding::Shift_JIS), r.getc) + } + end + end |