diff options
Diffstat (limited to 'test/ruby/test_gc.rb')
-rw-r--r-- | test/ruby/test_gc.rb | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index d43f8b8693..8c1f1b63bb 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -85,27 +85,31 @@ class TestGc < Test::Unit::TestCase assert_raise(ArgumentError){ GC.stat(:invalid) } end - def test_gc_reason + def test_latest_gc_info GC.start GC.stat[:heap_free_slot].times{ "a" + "b" } - assert_equal({:gc_by => :newobj}, - GC::Profiler.decode_flags(GC.stat[:last_collection_flags])) - end + assert_equal :newobj, GC.latest_gc_info[:gc_by] - def test_gc_reason_method GC.start - assert_equal({:major_by=>:nofree, :gc_by=>:method, :immediate_sweep=>true}, - GC::Profiler.decode_flags(GC.stat[:last_collection_flags])) - end + assert_equal :nofree, GC.latest_gc_info[:major_by] + assert_equal :method, GC.latest_gc_info[:gc_by] + assert_equal true, GC.latest_gc_info[:immediate_sweep] - def test_gc_reason_stress GC.stress = true - assert_equal({:major_by=>:stress, :gc_by=>:malloc, :immediate_sweep=>true}, - GC::Profiler.decode_flags(GC.stat[:last_collection_flags])) + assert_equal :stress, GC.latest_gc_info[:major_by] ensure GC.stress = false end + def test_latest_gc_info_argument + info = {} + GC.latest_gc_info(info) + + assert_not_empty info + assert_equal info[:gc_by], GC.latest_gc_info(:gc_by) + assert_raises(ArgumentError){ GC.latest_gc_info(:invalid) } + end + def test_singleton_method assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:42832]") GC.stress = true |