summaryrefslogtreecommitdiff
path: root/test/-ext-/symbol/test_inadvertent_creation.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-11 21:22:52 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-11 21:22:52 +0000
commita8ec4b2cf27739b9936f4eca71e0bd8dbd250fdc (patch)
tree629ec117216eb2ba8b38984066e7fca3650878f7 /test/-ext-/symbol/test_inadvertent_creation.rb
parentf0c968a778ee35f483a05c6d206eb815b1da177b (diff)
* string.c (sym_find): remove Symbol.find because we have Symbol GC now.
https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20140904Japan If you still want this, request again on Redmine. [Feature #7854] https://bugs.ruby-lang.org/issues/7854 * ext/-test-/symbol/init.c (sym_find): moved from string.c for tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/symbol/test_inadvertent_creation.rb')
-rw-r--r--test/-ext-/symbol/test_inadvertent_creation.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb
index 238d3625e6..465f032bbb 100644
--- a/test/-ext-/symbol/test_inadvertent_creation.rb
+++ b/test/-ext-/symbol/test_inadvertent_creation.rb
@@ -7,7 +7,7 @@ module Test_Symbol
prefix += "_#{Thread.current.object_id.to_s(36).tr('-', '_')}"
begin
name = "#{prefix}_#{rand(0x1000).to_s(16)}_#{Time.now.usec}"
- end while ::Symbol.find(name)
+ end while Bug::Symbol.find(name)
name
end
@@ -16,7 +16,7 @@ module Test_Symbol
end
def assert_not_interned(name, msg = nil)
- assert_not_send([::Symbol, :find, name], msg)
+ assert_not_send([Bug::Symbol, :find, name], msg)
end
def assert_not_interned_error(obj, meth, name, msg = nil)
@@ -262,5 +262,25 @@ module Test_Symbol
assert_raise(NameError) {mod.module_eval {attr_accessor(name)}}
assert_not_interned(name)
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
+ names = Array.new(1000) {noninterned_name("gc")}
+ names.each {|n| n.to_sym}
+ GC.start(immediate_sweep: false)
+ names.each do |n|
+ eval(":#{n}=")
+ assert_nothing_raised(TypeError, bug) {eval("proc{self.#{n} = nil}")}
+ end
+ end;
+ end
end
end