From a8f4f3c2d1aaf18f64905c0a15bab5219b7b301a Mon Sep 17 00:00:00 2001 From: mame Date: Mon, 14 Apr 2008 14:26:51 +0000 Subject: * test/ruby/test_objectspace.rb: add a test for ObjectSpace.count_objects. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_objectspace.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index a2d016495..6c28d6310 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -33,4 +33,19 @@ End deftest_id2ref(true) deftest_id2ref(false) deftest_id2ref(nil) + + def test_count_objects + h = {} + ObjectSpace.count_objects(h) + assert_kind_of(Hash, h) + assert(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) }) + assert(h.values.all? {|x| x.is_a?(Integer) }) + + h = ObjectSpace.count_objects + assert_kind_of(Hash, h) + assert(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) }) + assert(h.values.all? {|x| x.is_a?(Integer) }) + + assert_raise(TypeError) { ObjectSpace.count_objects(1) } + end end -- cgit