ruby-changes:44673
From: nobu <ko1@a...>
Date: Sat, 12 Nov 2016 17:17:04 +0900 (JST)
Subject: [ruby-changes:44673] nobu:r56746 (trunk): symbol/noninterned_name.rb
nobu 2016-11-12 17:16:58 +0900 (Sat, 12 Nov 2016) New Revision: 56746 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56746 Log: symbol/noninterned_name.rb * test/-ext-/symbol/noninterned_name.rb: split from test_inadvertent_creation.rb. Added files: trunk/test/-ext-/symbol/noninterned_name.rb Modified files: trunk/test/-ext-/symbol/test_inadvertent_creation.rb Index: test/-ext-/symbol/noninterned_name.rb =================================================================== --- test/-ext-/symbol/noninterned_name.rb (revision 0) +++ test/-ext-/symbol/noninterned_name.rb (revision 56746) @@ -0,0 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/noninterned_name.rb#L1 +require "-test-/symbol" + +module Test_Symbol + module NonInterned + module_function + + def noninterned_name(prefix = "") + prefix += "_#{Thread.current.object_id.to_s(36).tr('-', '_')}" + begin + name = "#{prefix}_#{rand(0x1000).to_s(16)}_#{Time.now.usec}" + end while Bug::Symbol.find(name) + name + end + end +end Property changes on: test/-ext-/symbol/noninterned_name.rb ___________________________________________________________________ Added: svn:eol-style + LF Index: test/-ext-/symbol/test_inadvertent_creation.rb =================================================================== --- test/-ext-/symbol/test_inadvertent_creation.rb (revision 56745) +++ test/-ext-/symbol/test_inadvertent_creation.rb (revision 56746) @@ -1,16 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/test_inadvertent_creation.rb#L1 # frozen_string_literal: false require 'test/unit' -require "-test-/symbol" +require_relative 'noninterned_name' module Test_Symbol class TestInadvertent < Test::Unit::TestCase - def noninterned_name(prefix = "") - prefix += "_#{Thread.current.object_id.to_s(36).tr('-', '_')}" - begin - name = "#{prefix}_#{rand(0x1000).to_s(16)}_#{Time.now.usec}" - end while Bug::Symbol.find(name) - name - end + include NonInterned def setup @obj = Object.new @@ -362,15 +356,9 @@ module Test_Symbol https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/test_inadvertent_creation.rb#L356 end def test_gc_attrset - assert_separately(['-r-test-/symbol', '-', '[ruby-core:62226] [Bug #9787]'], <<-'end;') # begin - bug = ARGV.shift - def noninterned_name(prefix = "") - prefix += "_#{Thread.current.object_id.to_s(36).tr('-', '_')}" - begin - name = "#{prefix}_#{rand(0x1000).to_s(16)}_#{Time.now.usec}" - end while Bug::Symbol.find(name) or Bug::Symbol.find(name + "=") - name - end + assert_separately(['-r-test-/symbol', '-r-ext-/symbol/noninterned_name', '-'], "#{<<-'begin;'}\n#{<<-"end;"}") + bug = '[ruby-core:62226] [Bug #9787]' + include Test_Symbol::NonInterned names = Array.new(1000) {noninterned_name("gc")} names.each {|n| n.to_sym} GC.start(immediate_sweep: false) @@ -378,6 +366,7 @@ module Test_Symbol https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/test_inadvertent_creation.rb#L366 eval(":#{n}=") assert_nothing_raised(TypeError, bug) {eval("proc{self.#{n} = nil}")} end + begin; end; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/