change to test/objectspace, don't rely on Object's shape not being "too complex"

This commit is contained in:
lukeg 2023-04-03 14:46:43 -04:00 committed by Aaron Patterson
parent 0c3f699268
commit d74b32db9d
No known key found for this signature in database
GPG Key ID: 953170BCB4FFAFC6

View File

@ -287,13 +287,17 @@ class TestObjSpace < Test::Unit::TestCase
JSON.parse(info) if defined?(JSON)
end
class TooComplex; end
if defined?(RubyVM::Shape)
def test_dump_too_complex_shape
RubyVM::Shape::SHAPE_MAX_VARIATIONS.times do
Object.new.instance_variable_set(:"@a#{_1}", 1)
TooComplex.new.instance_variable_set(:"@a#{_1}", 1)
end
tc = Object.new
tc = TooComplex.new
info = ObjectSpace.dump(tc)
assert_not_match(/"too_complex_shape"/, info)
tc.instance_variable_set(:@new_ivar, 1)
info = ObjectSpace.dump(tc)
assert_match(/"too_complex_shape":true/, info)