From 279fce05ae34bd05a01c8b377a5f1b13b701cf83 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Sun, 12 May 2013 19:49:56 +1000 Subject: ObjectSpace.count_objects was incorrectly checking if an object was already freed. Amended the count_objects test to ensure the correct distinction --- test/t/objectspace.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/t/objectspace.rb b/test/t/objectspace.rb index bf79da902..06319dcbb 100644 --- a/test/t/objectspace.rb +++ b/test/t/objectspace.rb @@ -16,4 +16,20 @@ assert('ObjectSpace.count_objects') do h0 = {:MRB_TT_FOO=>1000} h = ObjectSpace.count_objects(h0) assert_false(h0.has_key?(:MRB_TT_FOO)) + + GC.start + h_after = {} + h_before = ObjectSpace.count_objects + + objs = [] + 1000.times do + objs << {} + end + objs = nil + ObjectSpace.count_objects(h) + GC.start + ObjectSpace.count_objects(h_after) + + assert_equal(h_before[:MRB_TT_HASH] + 1000, h[:MRB_TT_HASH]) + assert_equal(h_before[:MRB_TT_HASH], h_after[:MRB_TT_HASH]) end \ No newline at end of file -- cgit v1.2.3