From ee29aade1a432cbd5e4d5ec6ea6ccb4fa87361be Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 7 Nov 2024 21:03:37 +0900 Subject: [Bug #20869] Discard read buffer and encoding converters at seeking --- test/ruby/test_io.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 5d4ede1e4f..0abc71a5b0 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -350,6 +350,19 @@ class TestIO < Test::Unit::TestCase end) end + def test_ungetc_with_seek + make_tempfile {|t| + t.open + t.write('0123456789') + t.rewind + + t.ungetc('a') + t.seek(2, :SET) + + assert_equal('2', t.getc) + } + end + def test_ungetbyte make_tempfile {|t| t.open @@ -373,6 +386,19 @@ class TestIO < Test::Unit::TestCase } end + def test_ungetbyte_with_seek + make_tempfile {|t| + t.open + t.write('0123456789') + t.rewind + + t.ungetbyte('a'.ord) + t.seek(2, :SET) + + assert_equal('2'.ord, t.getbyte) + } + end + def test_each_byte pipe(proc do |w| w << "abc def" -- cgit v1.2.3