ruby-changes:32476
From: nobu <ko1@a...>
Date: Fri, 10 Jan 2014 18:42:36 +0900 (JST)
Subject: [ruby-changes:32476] nobu:r44555 (trunk): test_weakref.rb: find collected weakref
nobu 2014-01-10 18:42:31 +0900 (Fri, 10 Jan 2014) New Revision: 44555 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44555 Log: 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. Modified files: trunk/test/test_weakref.rb Index: test/test_weakref.rb =================================================================== --- test/test_weakref.rb (revision 44554) +++ test/test_weakref.rb (revision 44555) @@ -19,9 +19,14 @@ class TestWeakRef < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_weakref.rb#L19 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/