aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_weakref.rb
diff options
context:
space:
mode:
authorshirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-24 04:01:33 +0000
committershirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-24 04:01:33 +0000
commit82cac33ecb45abf68a98e5f30849502e50579242 (patch)
tree3a7ec7c41891da16376353959d14c90353c11044 /test/test_weakref.rb
parent5611df706e5685fbe03412588d23ee31f13c671d (diff)
downloadruby-82cac33ecb45abf68a98e5f30849502e50579242.tar.gz
Fix finalize of WeakRef
* gc.c (wmap_final_func): remove WeakRef object reference from the array. * gc.c (wmap_finalize): remove recycled object references from weak map hash properly. How to get object reference from object id was wrong. st_delete() doesn't work properly if key and value arguments are same. The key of obj2wmap is referenced object and the value of obj2wmap is WeakRef array. * gc.c (wmap_aset): obj2wmap should contain WeakRef array in the definition. * test/test_weakref.rb (TestWeakRef#test_not_reference_different_object): add a test for above. [ruby-core:49044] [Bug #7304] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_weakref.rb')
-rw-r--r--test/test_weakref.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_weakref.rb b/test/test_weakref.rb
index 0f943cdf12..6c80f5924d 100644
--- a/test/test_weakref.rb
+++ b/test/test_weakref.rb
@@ -21,4 +21,23 @@ class TestWeakRef < Test::Unit::TestCase
ObjectSpace.garbage_collect
assert_raise(WeakRef::RefError) {weak.to_s}
end
+
+ def test_not_reference_different_object
+ bug7304 = '[ruby-core:49044]'
+ weakrefs = []
+ 3.times do
+ obj = Object.new
+ def obj.foo; end
+ weakrefs << WeakRef.new(obj)
+ ObjectSpace.garbage_collect
+ end
+ assert_nothing_raised(NoMethodError, bug7304) {
+ weakrefs.each do |weak|
+ begin
+ weak.foo
+ rescue WeakRef::RefError
+ end
+ end
+ }
+ end
end