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

ruby-changes:66894

From: Nobuyoshi <ko1@a...>
Date: Tue, 27 Jul 2021 12:00:13 +0900 (JST)
Subject: [ruby-changes:66894] ed51e8b8fa (master): Make GCed during suppressing the warning

https://git.ruby-lang.org/ruby.git/commit/?id=ed51e8b8fa

From ed51e8b8fa9f7e811e69de30f7695dc2242e8e69 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 27 Jul 2021 11:47:11 +0900
Subject: Make GCed during suppressing the warning

Consume the VM stack more, to make the target object get GCed with
more probability during suppressing the warning.
---
 test/ruby/test_gc.rb | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index 4df9775..02f86a2 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -451,14 +451,17 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L451
       result << :c2
       raise
     end
-    tap {
-      tap {
+    gen = proc do |depth|
+      if depth > 0
+        gen[depth-1]
+      else
         obj = Object.new
         ObjectSpace.define_finalizer(obj, c1)
         ObjectSpace.define_finalizer(obj, c2)
         obj = nil
-      }
-    }
+      end
+    end
+    gen[100]
     EnvUtil.suppress_warning {GC.start}
     skip "finalizers did not get run" if result.empty?
     assert_equal([:c1, :c2], result)
@@ -474,14 +477,17 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L477
       @result << :c2
       raise
     end
-    tap {
-      tap {
+    gen = proc do |depth|
+      if depth > 0
+        gen[depth-1]
+      else
         obj = Object.new
         ObjectSpace.define_finalizer(obj, method(:c1))
         ObjectSpace.define_finalizer(obj, method(:c2))
         obj = nil
-      }
-    }
+      end
+    end
+    gen[100]
     EnvUtil.suppress_warning {GC.start}
     skip "finalizers did not get run" if @result.empty?
     assert_equal([:c1, :c2], @result)
-- 
cgit v1.1


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

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