From af634f8455ecb48209637bf8c748dad7136b9c9f Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 14 May 2009 07:07:55 +0000 Subject: * ext/stringio/stringio.c (strio_ungetbyte): encoding should not be effective. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ruby/test_io.rb') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index f456779880..69e3666cff 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -118,6 +118,22 @@ class TestIO < Test::Unit::TestCase r.close end + def test_ungetbyte + t = make_tempfile + t.open + t.ungetbyte(0x41) + assert_equal(0x41, t.getbyte) + t.rewind + t.ungetbyte("qux") + assert_equal("quxfoo\n", t.gets) + t.set_encoding("utf-8") + t.ungetbyte(0x89) + t.ungetbyte(0x8e) + t.ungetbyte("\xe7") + t.ungetbyte("\xe7\xb4\x85") + assert_equal("\u7d05\u7389bar\n", t.gets) + end + def test_each_byte r, w = IO.pipe w << "abc def" -- cgit v1.2.3