diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 14:28:45 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 14:28:45 +0000 |
commit | 1b821cb4a32b40ba6392abbba6c941aceb47e54d (patch) | |
tree | 973b6a8ef59603393a166b6248f1edcb93409f35 /test/ruby/test_io_m17n.rb | |
parent | e32e9a06e4e05dbe38ae8d42af55db3fd1899469 (diff) | |
download | ruby-1b821cb4a32b40ba6392abbba6c941aceb47e54d.tar.gz |
* io.c (io_ungetbyte): renamed from io_ungetc.
(rb_io_ungetbyte): new method.
(rb_io_ungetc): push back into character buffer if enc2 is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io_m17n.rb')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 070987ad3c..b059f70ff3 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -239,14 +239,30 @@ EOT with_tmpdir { src = "before \e$B\x23\x30\x23\x31\e(B after".force_encoding("iso-2022-jp") generate_file('tmp', src) - assert_raise(NotImplementedError) do - s = open("tmp", "r:iso-2022-jp:euc-jp") {|f| - f.ungetc("0".force_encoding("euc-jp")) - f.read - } - assert_equal(Encoding.find("euc-jp"), s.encoding) - assert_str_equal(("0" + src).encode("euc-jp"), s) - end + s = open("tmp", "r:iso-2022-jp:euc-jp") {|f| + f.ungetc("0".force_encoding("euc-jp")) + f.read + } + assert_equal(Encoding.find("euc-jp"), s.encoding) + assert_str_equal("0" + src.encode("euc-jp"), s) + } + end + + def test_ungetc_stateful_conversion2 + with_tmpdir { + src = "before \e$B\x23\x30\x23\x31\e(B after".force_encoding("iso-2022-jp") + former = "before \e$B\x23\x30\e(B".force_encoding("iso-2022-jp") + rs = "\e$B\x23\x30\e(B".force_encoding("iso-2022-jp") + latter = "\e$B\x23\x31\e(B after".force_encoding("iso-2022-jp") + generate_file('tmp', src) + s = open("tmp", "r:iso-2022-jp:euc-jp") {|f| + assert_equal(former.encode("euc-jp", "iso-2022-jp"), + f.gets(rs.encode("euc-jp", "iso-2022-jp"))) + f.ungetc("0") + f.read + } + assert_equal(Encoding.find("euc-jp"), s.encoding) + assert_str_equal("0" + latter.encode("euc-jp"), s) } end |