From 57d0c36a2821f01f71eda14695476af9a558365d Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 27 Mar 2017 14:47:38 +0000 Subject: merge revision(s) 57972: [Backport #13198] 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/branches/ruby_2_3@58154 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 c8af2f5b4d..21edf39776 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -243,6 +243,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