summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-27 14:47:38 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-27 14:47:38 +0000
commit57d0c36a2821f01f71eda14695476af9a558365d (patch)
tree61abbdcd6104dfb6983608e87c0ada7ad9004397 /test
parent316f37b18769d5a161df67ebe3edf502d043fc96 (diff)
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 <nobu@ruby-lang.org>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_tempfile.rb7
1 files changed, 7 insertions, 0 deletions
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 = []