diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-11-07 21:03:37 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-11-07 21:03:37 +0900 |
| commit | ee29aade1a432cbd5e4d5ec6ea6ccb4fa87361be (patch) | |
| tree | 495aef12a79c418b9cbfa5b440fcf96704c17b30 /test/ruby | |
| parent | 1701ddea73cf482289361c7559ad42e2694f65f1 (diff) | |
[Bug #20869] Discard read buffer and encoding converters at seeking
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12023
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io.rb | 26 |
1 files changed, 26 insertions, 0 deletions
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" |
