1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 44555:

test_weakref.rb: find collected weakref

	* test/test_weakref.rb (test_recycled): retry and find a WeakRef
  whose the target is collected, to fix circumstance dependent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-02-05 15:47:37 +00:00
parent eef4a3cd72
commit 1f478676c4
2 changed files with 11 additions and 6 deletions

View file

@ -19,9 +19,14 @@ class TestWeakRef < Test::Unit::TestCase
end
def test_recycled
weak = make_weakref
ObjectSpace.garbage_collect
ObjectSpace.garbage_collect
weaks = []
weak = nil
100.times do
weaks << make_weakref
ObjectSpace.garbage_collect
ObjectSpace.garbage_collect
break if weak = weaks.find {|w| !w.weakref_alive?}
end
assert_raise(WeakRef::RefError) {weak.to_s}
assert_not_predicate(weak, :weakref_alive?)
end