diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a3ac12765c..6990de1862 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1360,21 +1360,23 @@ class TestIO < Test::Unit::TestCase def test_pos_with_getc bug6179 = '[ruby-core:43497]' t = make_tempfile - open(t.path, "w") do |f| - f.write "0123456789" - end - - open(t.path, "r") do |f| - assert_equal 0, f.pos - assert_equal '0', f.getc - assert_equal 1, f.pos - assert_equal '1', f.getc - assert_equal 2, f.pos - assert_equal '2', f.getc - assert_equal 3, f.pos - assert_equal '3', f.getc - assert_equal 4, f.pos - assert_equal '4', f.getc + ["", "t", "b"].each do |mode| + open(t.path, "w#{mode}") do |f| + f.write "0123456789\n" + end + + open(t.path, "r#{mode}") do |f| + assert_equal 0, f.pos, "mode=r#{mode}" + assert_equal '0', f.getc, "mode=r#{mode}" + assert_equal 1, f.pos, "mode=r#{mode}" + assert_equal '1', f.getc, "mode=r#{mode}" + assert_equal 2, f.pos, "mode=r#{mode}" + assert_equal '2', f.getc, "mode=r#{mode}" + assert_equal 3, f.pos, "mode=r#{mode}" + assert_equal '3', f.getc, "mode=r#{mode}" + assert_equal 4, f.pos, "mode=r#{mode}" + assert_equal '4', f.getc, "mode=r#{mode}" + end end end |