diff options
| author | Ryan Scott <[email protected]> | 2013-05-12 18:42:21 +1000 |
|---|---|---|
| committer | Ryan Scott <[email protected]> | 2013-05-12 18:42:21 +1000 |
| commit | 0d4227ac04832a3bb4010d701ebda2c97c034da6 (patch) | |
| tree | bfb1207c125d3b22afea7b1571c04b99888e8752 /test/t/objectspace.rb | |
| parent | 37e3643f8f048d8387419a43abc51236eadbeb1e (diff) | |
| download | mruby-0d4227ac04832a3bb4010d701ebda2c97c034da6.tar.gz mruby-0d4227ac04832a3bb4010d701ebda2c97c034da6.zip | |
Implemented ObjectSpace.count_objects to count the number of allocated objects for each type
Diffstat (limited to 'test/t/objectspace.rb')
| -rw-r--r-- | test/t/objectspace.rb | 19 |
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 |
