[前][次][番号順一覧][スレッド一覧]

ruby-changes:32067

From: nobu <ko1@a...>
Date: Thu, 12 Dec 2013 15:17:27 +0900 (JST)
Subject: [ruby-changes:32067] nobu:r44146 (trunk): test_weakref.rb: use single level WeakRef

nobu	2013-12-12 15:17:23 +0900 (Thu, 12 Dec 2013)

  New Revision: 44146

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44146

  Log:
    test_weakref.rb: use single level WeakRef
    
    * test/test_weakref.rb (make_weakref): return single level
      WeakRef, instead of multiple level, since the second level
      object may be still alive even after the final object get
      finalized, in test_recycled.
    
    * test/test_weakref.rb (test_ref): move living object assertions
      from test_recycled.

  Modified files:
    trunk/test/test_weakref.rb
Index: test/test_weakref.rb
===================================================================
--- test/test_weakref.rb	(revision 44145)
+++ test/test_weakref.rb	(revision 44146)
@@ -4,21 +4,22 @@ require_relative './ruby/envutil' https://github.com/ruby/ruby/blob/trunk/test/test_weakref.rb#L4
 
 class TestWeakRef < Test::Unit::TestCase
   def make_weakref(level = 10)
-    obj = Object.new
-    str = obj.to_s
-    level.times {obj = WeakRef.new(obj)}
-    return WeakRef.new(obj), str
+    if level > 0
+      make_weakref(level - 1)
+    else
+      WeakRef.new(Object.new)
+    end
   end
 
   def test_ref
-    weak, str = make_weakref
-    assert_equal(str, weak.to_s)
+    obj = Object.new
+    weak = WeakRef.new(obj)
+    assert_equal(obj.to_s, weak.to_s)
+    assert_predicate(weak, :weakref_alive?)
   end
 
   def test_recycled
-    weak, str = make_weakref
-    assert_nothing_raised(WeakRef::RefError) {weak.to_s}
-    assert_predicate(weak, :weakref_alive?)
+    weak = make_weakref
     ObjectSpace.garbage_collect
     ObjectSpace.garbage_collect
     assert_raise(WeakRef::RefError) {weak.to_s}

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]