summaryrefslogtreecommitdiffhomepage
path: root/test/t/objectspace.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/t/objectspace.rb')
-rw-r--r--test/t/objectspace.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/t/objectspace.rb b/test/t/objectspace.rb
new file mode 100644
index 000000000..bf79da902
--- /dev/null
+++ b/test/t/objectspace.rb
@@ -0,0 +1,19 @@
+
+assert('ObjectSpace.count_objects') do
+ h = {}
+ ObjectSpace.count_objects(h)
+ assert_kind_of(Hash, h)
+ assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
+ assert_true(h.values.all? {|x| x.is_a?(Integer) })
+
+ h = ObjectSpace.count_objects
+ assert_kind_of(Hash, h)
+ assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
+ assert_true(h.values.all? {|x| x.is_a?(Integer) })
+
+ assert_raise(TypeError) { ObjectSpace.count_objects(1) }
+
+ h0 = {:MRB_TT_FOO=>1000}
+ h = ObjectSpace.count_objects(h0)
+ assert_false(h0.has_key?(:MRB_TT_FOO))
+ end \ No newline at end of file