From 279d31f11de8bd0727626a6c32ccd72e1da76508 Mon Sep 17 00:00:00 2001 From: glass Date: Tue, 14 Mar 2017 12:53:32 +0000 Subject: Fix bug of Tempfile#size if nothing is written [Bug #13198] * lib/tempfile.rb (Tempfile#size): Fix its behavior when nothing is written. Tempfile#size should return 0 in this case. The patch is from nobu . git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_tempfile.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 7f7f75c7db..a2b272747e 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -247,6 +247,13 @@ puts Tempfile.new('foo').path assert_equal 5, t.size end + def test_size_on_empty_file + t = tempfile("foo") + t.write("") + t.close + assert_equal 0, t.size + end + def test_concurrency threads = [] tempfiles = [] -- cgit v1.2.3