summaryrefslogtreecommitdiff
path: root/test/objspace
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2022-02-01 21:36:29 +0000
committerPeter Zhu <peter@peterzhu.ca>2022-02-03 15:07:35 -0500
commit9fab2c1a1a5f5e429eb88eac29d250685dcc4354 (patch)
tree07b1d1f6e8beff5be7654a25faa29672dbc3746a /test/objspace
parenta3caf196d9d060341924c1e37dd9f60dde8252f6 (diff)
downloadruby-9fab2c1a1a5f5e429eb88eac29d250685dcc4354.tar.gz
Add the size pool slot size to the output of ObjectSpace.dump/dump_all
Diffstat (limited to 'test/objspace')
-rw-r--r--test/objspace/test_objspace.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index b7342e899b..34d9dd76ec 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -431,6 +431,27 @@ class TestObjSpace < Test::Unit::TestCase
end
end
+ def test_dump_objects_dumps_page_slot_sizes
+ assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
+ begin;
+ def dump_my_heap_please
+ ObjectSpace.dump_all(output: $stdout)
+ end
+
+ p $stdout == dump_my_heap_please
+ end;
+ assert_equal 'true', output.pop
+ assert(output.count > 1)
+ output.each { |l|
+ obj = JSON.parse(l)
+ next if obj["type"] == "ROOT"
+
+ assert(obj["slot_size"] != nil)
+ assert(obj["slot_size"] % GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] == 0)
+ }
+ end
+ end
+
def test_dump_escapes_method_name
method_name = "foo\"bar"
klass = Class.new do
@@ -449,6 +470,13 @@ class TestObjSpace < Test::Unit::TestCase
ObjectSpace.trace_object_allocations_stop
end
+ def test_dump_includes_slot_size
+ str = "TEST"
+ dump = ObjectSpace.dump(str)
+
+ assert_includes dump, "\"slot_size\":#{GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE]}"
+ end
+
def test_dump_reference_addresses_match_dump_all_addresses
assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
begin;