diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 642c8f4430..19b4f0ebf6 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1,6 +1,15 @@ require 'test/unit' +require 'tmpdir' class TestIO < Test::Unit::TestCase + def mkcdtmpdir + Dir.mktmpdir {|d| + Dir.chdir(d) { + yield + } + } + end + def test_gets_rs r, w = IO.pipe w.print "\377xyz" @@ -8,4 +17,15 @@ class TestIO < Test::Unit::TestCase assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]") r.close end + + def test_readpartial_pos + mkcdtmpdir { + open("foo", "w") {|f| f << "abc" } + open("foo") {|f| + f.seek(0) + assert_equal("ab", f.readpartial(2)) + assert_equal(2, f.pos) + } + } + end end |