summaryrefslogtreecommitdiff
path: root/test/objspace/test_objspace.rb
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-12-15 13:42:24 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2022-12-15 13:41:47 -0800
commite9ba3042e13313944fd2695731d0d7498532b80f (patch)
treef4a9c06093de20ad0f2ce8971db8dcb9cba260ac /test/objspace/test_objspace.rb
parentc505448cdbd4cd1a52ed7108095f6738d29b3419 (diff)
Indicate if a shape is too_complex in ObjectSpace#dump
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6939
Diffstat (limited to 'test/objspace/test_objspace.rb')
-rw-r--r--test/objspace/test_objspace.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 7eda077260..f0f294c31a 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -272,6 +272,35 @@ class TestObjSpace < Test::Unit::TestCase
JSON.parse(info) if defined?(JSON)
end
+ def test_dump_too_complex_shape
+ if defined?(RubyVM::Shape)
+ RubyVM::Shape::SHAPE_MAX_VARIATIONS.times do
+ Object.new.instance_variable_set(:"@a#{_1}", 1)
+ end
+
+ tc = Object.new
+ tc.instance_variable_set(:@new_ivar, 1)
+ info = ObjectSpace.dump(tc)
+ assert_match(/"too_complex_shape":true/, info)
+ if defined?(JSON)
+ assert_true(JSON.parse(info)["too_complex_shape"])
+ end
+ end
+ end
+
+ class NotTooComplex ; end
+
+ def test_dump_not_too_complex_shape
+ tc = NotTooComplex.new
+ tc.instance_variable_set(:@new_ivar, 1)
+ info = ObjectSpace.dump(tc)
+
+ assert_not_match(/"too_complex_shape"/, info)
+ if defined?(JSON)
+ assert_nil(JSON.parse(info)["too_complex_shape"])
+ end
+ end
+
def test_dump_to_default
line = nil
info = nil