diff options
Diffstat (limited to 'test/ruby/test_file.rb')
-rw-r--r-- | test/ruby/test_file.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 637dced6a6..4459c3edd9 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -226,4 +226,23 @@ class TestFile < Test::Unit::TestCase assert(File.fnmatch('**/foo', 'c:/root/foo', File::FNM_PATHNAME)) end + def test_truncate_wbuf # [ruby-dev:24191] + f = Tempfile.new("test-truncate") + f.puts "abc" + f.truncate(0) + f.puts "def" + f.close + assert_equal("\0\0\0\0def\n", File.read(f.path)) + end + + def test_truncate_rbuf # [ruby-dev:24197] + f = Tempfile.new("test-truncate") + f.puts "abc" + f.puts "def" + f.close + f.open + assert_equal("abc\n", f.gets) + f.truncate(3) + assert_equal(nil, f.gets) + end end |