diff options
author | Jean Boussier <[email protected]> | 2023-10-30 12:29:59 +0100 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-10-31 12:07:54 -0400 |
commit | 4aacc559d99988f395eced3534c7a6938bd356c8 (patch) | |
tree | a33af6b2ae7ae803053dad304687b321cdd73e93 /test/ruby/test_shapes.rb | |
parent | 85ad1025328989bb4e10436aed121b9136b0c8bf (diff) |
Handle running out of shapes in `Object#dup`
There is a handful of call sites where we may transition to
OBJ_TOO_COMPLEX_SHAPE if we just ran out of shapes, but that
weren't handling it properly.
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index af2af5c778..6d98daf233 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -226,6 +226,32 @@ class TestShapes < Test::Unit::TestCase end; end + def test_run_out_of_shape_rb_obj_copy_ivar + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class A + def initialize + init # Avoid right sizing + end + + def init + @a = @b = @c = @d = @e = @f = 1 + end + end + + a = A.new + + o = Object.new + i = 0 + while RubyVM::Shape.shapes_available > 1 + o.instance_variable_set(:"@i#{i}", 1) + i += 1 + end + + a.dup + end; + end + def test_use_all_shapes_module assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |