зеркало из https://github.com/github/ruby.git
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/trunk@44555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e85e95c409
Коммит
b89a88f043
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче