summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-01-28 10:15:27 -0500
committerPeter Zhu <peter@peterzhu.ca>2025-01-30 11:48:14 -0500
commitd729c1575e794bb9dafd1f7fcb0740735537504a (patch)
tree95825cd8b332c90478fa5220d911363ffb229fb1 /test
parentf0dc9dcdc7a3b15b3192b1503a3c3d9eec3ada06 (diff)
Output object_id in ObjectSpace.dump
Outputs the object ID in the dump for objects that have it seen.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12657
Diffstat (limited to 'test')
-rw-r--r--test/objspace/test_objspace.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index e0dde3621c..939092e1c1 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -486,6 +486,20 @@ class TestObjSpace < Test::Unit::TestCase
assert_match(/"value":"foobar\h+"/, dump)
end
+ def test_dump_outputs_object_id
+ obj = Object.new
+
+ # Doesn't output object_id when it has not been seen
+ dump = ObjectSpace.dump(obj)
+ assert_not_include(dump, "\"object_id\"")
+
+ id = obj.object_id
+
+ # Outputs object_id when it has been seen
+ dump = ObjectSpace.dump(obj)
+ assert_include(dump, "\"object_id\":#{id}")
+ end
+
def test_dump_includes_imemo_type
assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
begin;