1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/objspace/objspace.c: add a new method `reachable_objects_from_root'.

ObjectSpace.reachable_objects_from_root returns all objects refered
  from root (called "root objects").
  This feature is for deep object analysis.
* test/objspace/test_objspace.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-10-16 06:13:41 +00:00
parent e775a930e1
commit ede6826186
3 changed files with 86 additions and 0 deletions

View file

@ -97,6 +97,18 @@ class TestObjSpace < Test::Unit::TestCase
eom
end
def test_reachable_objects_from_root
root_objects = ObjectSpace.reachable_objects_from_root
assert_operator(root_objects.size, :>, 0)
root_objects.each{|category, objects|
assert_kind_of(String, category)
assert_kind_of(Array, objects)
assert_operator(objects.size, :>, 0)
}
end
def test_reachable_objects_size
assert_separately %w[--disable-gem -robjspace], __FILE__, __LINE__, <<-'eom'
ObjectSpace.each_object{|o|