mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
symbol/noninterned_name.rb
* test/-ext-/symbol/noninterned_name.rb: split from test_inadvertent_creation.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
04e83c536e
commit
2c0d3e2a2e
2 changed files with 21 additions and 17 deletions
15
test/-ext-/symbol/noninterned_name.rb
Normal file
15
test/-ext-/symbol/noninterned_name.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
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
|
|
@ -1,16 +1,10 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: false
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require "-test-/symbol"
|
require_relative 'noninterned_name'
|
||||||
|
|
||||||
module Test_Symbol
|
module Test_Symbol
|
||||||
class TestInadvertent < Test::Unit::TestCase
|
class TestInadvertent < Test::Unit::TestCase
|
||||||
def noninterned_name(prefix = "")
|
include NonInterned
|
||||||
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
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@obj = Object.new
|
@obj = Object.new
|
||||||
|
@ -362,15 +356,9 @@ module Test_Symbol
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gc_attrset
|
def test_gc_attrset
|
||||||
assert_separately(['-r-test-/symbol', '-', '[ruby-core:62226] [Bug #9787]'], <<-'end;') # begin
|
assert_separately(['-r-test-/symbol', '-r-ext-/symbol/noninterned_name', '-'], "#{<<-'begin;'}\n#{<<-"end;"}")
|
||||||
bug = ARGV.shift
|
bug = '[ruby-core:62226] [Bug #9787]'
|
||||||
def noninterned_name(prefix = "")
|
include Test_Symbol::NonInterned
|
||||||
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
|
|
||||||
names = Array.new(1000) {noninterned_name("gc")}
|
names = Array.new(1000) {noninterned_name("gc")}
|
||||||
names.each {|n| n.to_sym}
|
names.each {|n| n.to_sym}
|
||||||
GC.start(immediate_sweep: false)
|
GC.start(immediate_sweep: false)
|
||||||
|
@ -378,6 +366,7 @@ module Test_Symbol
|
||||||
eval(":#{n}=")
|
eval(":#{n}=")
|
||||||
assert_nothing_raised(TypeError, bug) {eval("proc{self.#{n} = nil}")}
|
assert_nothing_raised(TypeError, bug) {eval("proc{self.#{n} = nil}")}
|
||||||
end
|
end
|
||||||
|
begin;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue