diff options
Diffstat (limited to 'test/ruby/test_time.rb')
-rw-r--r-- | test/ruby/test_time.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index d3a8645024..a0d65b6495 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -1090,6 +1090,17 @@ class TestTime < Test::Unit::TestCase assert_equal("366", t.strftime("%j")) end + def test_strftime_no_hidden_garbage + fmt = %w(Y m d).map { |x| "%#{x}" }.join('-') # defeats optimization + t = Time.at(0) + ObjectSpace.count_objects(res = {}) # creates strings on first call + before = ObjectSpace.count_objects(res)[:T_STRING] + val = t.strftime(fmt) + after = ObjectSpace.count_objects(res)[:T_STRING] + assert_equal before + 1, after, 'only new string is the created one' + assert_equal '1970-01-01', val + end + def test_num_exact_error bad = EnvUtil.labeled_class("BadValue").new x = EnvUtil.labeled_class("Inexact") do |