summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-22 12:53:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-22 12:53:05 +0000
commitae6ebbb3fa67bdc72e4ba65b81d798b1f6ecd800 (patch)
tree1525eef45c05f9c7258b77c0b00946124d1f9279
parentb906f78855989a5907d49d317e8e586b41818eaa (diff)
fix mortal_dynamic_symbol count
* test/objspace/test_objspace.rb (test_count_symbols): exclude a dynamic symbol which has been turned into immortal by define_method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/objspace/test_objspace.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 21e1341ff3..c5c8147f5f 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -419,13 +419,18 @@ class TestObjSpace < Test::Unit::TestCase
end
def test_count_symbols
+ assert_separately(%w[-robjspace], "#{<<~';;;'}")
+ h0 = ObjectSpace.count_symbols
+
syms = (1..128).map{|i| ("xyzzy#{i}_#{Process.pid}_#{rand(1_000_000)}_" * 128).to_sym}
- c = Class.new{define_method(syms[-1]){}}
+ syms << 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
+ m = proc {h0.inspect + "\n" + h.inspect}
+ assert_equal 127, h[:mortal_dynamic_symbol] - h0[:mortal_dynamic_symbol], m
+ assert_equal 1, h[:immortal_dynamic_symbol] - h0[:immortal_dynamic_symbol], m
+ assert_operator h[:immortal_static_symbol], :>=, Object.methods.size, m
+ assert_equal h[:immortal_symbol], h[:immortal_dynamic_symbol] + h[:immortal_static_symbol], m
+ ;;;
end
end