Skip to content

Commit

Permalink
change to test/objectspace, don't rely on Object's shape not being "t…
Browse files Browse the repository at this point in the history
…oo complex"
  • Loading branch information
luke-gru authored and tenderlove committed May 18, 2023
1 parent 0c3f699 commit d74b32d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/objspace/test_objspace.rb
Expand Up @@ -287,13 +287,17 @@ def test_dump_flags
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)
Expand Down

0 comments on commit d74b32d

Please sign in to comment.