From ae6ebbb3fa67bdc72e4ba65b81d798b1f6ecd800 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 22 Jun 2017 12:53:05 +0000 Subject: 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 --- test/objspace/test_objspace.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'test/objspace') 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 -- cgit v1.2.3