diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-21 11:30:24 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-21 11:30:24 +0000 |
commit | cd371c46ddc1f508082da0d246ac9bfe70937404 (patch) | |
tree | 83582e2545ff4ad7e3c37770bf0dae3bbce94e61 /test | |
parent | 356ba58f8b19af823dcf6ed239112af9df82541c (diff) | |
download | ruby-cd371c46ddc1f508082da0d246ac9bfe70937404.tar.gz |
* ext/objspace/objspace.c: add a new method ObjectSpace.count_symbols.
[Feature #11158]
* symbol.c (rb_sym_immortal_count): added to count immortal symbols.
* symbol.h: ditto.
* test/objspace/test_objspace.rb: add a test for this method.
* NEWS: describe about this method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/objspace/test_objspace.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 3036b879bb..2acc35469f 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -351,4 +351,15 @@ class TestObjSpace < Test::Unit::TestCase } assert_operator i, :>, 0 end + + def test_count_symbols + syms = (1..128).map{|i| ("xyzzy#{i}" * 128).to_sym} + c = Class.new{define_method(syms[-1]){}} + + h = ObjectSpace.count_symbols + assert_operator h[:mortal_dynamic_symbol], :>=, 128, h.inspect + assert_operator h[:immortal_dynamic_symbol], :>=, 1, h.inspect + assert_operator h[:immortal_static_symbol], :>=, Object.methods.size, h.inspect + assert_equal h[:immortal_symbol], h[:immortal_dynamic_symbol] + h[:immortal_static_symbol], h.inspect + end end |