diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_sprintf.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_time.rb | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index a07ac7908b..163d37256c 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -524,12 +524,17 @@ class TestSprintf < Test::Unit::TestCase end def test_no_hidden_garbage + skip unless Thread.list.size == 1 + fmt = [4, 2, 2].map { |x| "%0#{x}d" }.join('-') # defeats optimization ObjectSpace.count_objects(res = {}) # creates strings on first call + GC.disable before = ObjectSpace.count_objects(res)[:T_STRING] val = sprintf(fmt, 1970, 1, 1) 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 + ensure + GC.enable end end diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index d89a093303..50ac569c4e 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -1109,11 +1109,14 @@ class TestTime < Test::Unit::TestCase fmt = %w(Y m d).map { |x| "%#{x}" }.join('-') # defeats optimization t = Time.at(0).getutc ObjectSpace.count_objects(res = {}) # creates strings on first call + GC.disable 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 + ensure + GC.enable end def test_num_exact_error |