ruby-changes:47031
From: nobu <ko1@a...>
Date: Thu, 22 Jun 2017 21:53:10 +0900 (JST)
Subject: [ruby-changes:47031] nobu:r59146 (trunk): fix mortal_dynamic_symbol count
nobu 2017-06-22 21:53:05 +0900 (Thu, 22 Jun 2017) New Revision: 59146 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59146 Log: 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. Modified files: trunk/test/objspace/test_objspace.rb Index: test/objspace/test_objspace.rb =================================================================== --- test/objspace/test_objspace.rb (revision 59145) +++ test/objspace/test_objspace.rb (revision 59146) @@ -419,13 +419,18 @@ class TestObjSpace < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L419 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/