summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_weakref.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/test_weakref.rb b/test/test_weakref.rb
index 85820b17b8..f12e943423 100644
--- a/test/test_weakref.rb
+++ b/test/test_weakref.rb
@@ -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