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

ruby-changes:66189

From: Koichi <ko1@a...>
Date: Wed, 12 May 2021 17:40:53 +0900 (JST)
Subject: [ruby-changes:66189] 523a6998dd (master): Use another class for the comparison.

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

From 523a6998dd45eb910ccd3fe6a8d9d008f7a12cf2 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Wed, 12 May 2021 17:35:57 +0900
Subject: Use another class for the comparison.

`memsize_of(Object.new)` can be changed with past ivar creation
history for Object instances (another Object instance has 4 or
more ivars, next created Object instance has the area for the
ivars). So use antoher class for the comparison.
---
 test/objspace/test_objspace.rb | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 812b081..8a0b6fb 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -106,10 +106,9 @@ class TestObjSpace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L106
   end
 
   def test_memsize_of_iseq
-    skip # To debug
-
     iseqw = RubyVM::InstructionSequence.compile('def a; a = :b; a; end')
-    base_obj_size = ObjectSpace.memsize_of(Object.new)
+    # Use anonymous class as a basic object size because size of Object.new can be increased
+    base_obj_size = ObjectSpace.memsize_of(Class.new.new) 
     assert_operator(ObjectSpace.memsize_of(iseqw), :>, base_obj_size)
   end
 
-- 
cgit v1.1


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

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