diff options
| author | Ryan Scott <[email protected]> | 2013-05-12 19:49:56 +1000 |
|---|---|---|
| committer | Ryan Scott <[email protected]> | 2013-05-12 19:49:56 +1000 |
| commit | 279fce05ae34bd05a01c8b377a5f1b13b701cf83 (patch) | |
| tree | 8467ebd6300a1a5612971d7f8b7f072cd23d53a4 /test | |
| parent | c2d1105aa9190f12577e7b63c22f659c1d1155ab (diff) | |
| download | mruby-279fce05ae34bd05a01c8b377a5f1b13b701cf83.tar.gz mruby-279fce05ae34bd05a01c8b377a5f1b13b701cf83.zip | |
ObjectSpace.count_objects was incorrectly checking if an object was already freed. Amended the count_objects test to ensure the correct distinction
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/objectspace.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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 |
