summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_objectspace.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb
index a2d0164954..6c28d63108 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