diff options
author | Jean Boussier <[email protected]> | 2023-11-06 11:10:37 +0100 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2023-11-06 12:39:52 +0100 |
commit | 4a6bdbd6dc160c4614105f0478d398b2222429e0 (patch) | |
tree | acb48dd9fa5f6eec673cdde79fcf6fbe0bc49338 /test/ruby/test_shapes.rb | |
parent | 66769dcd12b1f323e7d38ab1280700a6ffe509d7 (diff) |
generic_ivar_set: properly check for TOO_COMPLEX on capacity transition
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 1135daecbe..8755da9d25 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -318,7 +318,7 @@ class TestShapes < Test::Unit::TestCase end; end - def test_run_out_of_shape_generic_ivar_set + def test_run_out_of_shape_generic_instance_variable_set assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; class TooComplex < Hash @@ -345,6 +345,36 @@ class TestShapes < Test::Unit::TestCase end; end + def test_run_out_of_shape_generic_ivar_set + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class Hi < String + def initialize + 8.times do |i| + instance_variable_set("@ivar_#{i}", i) + end + end + + def transition + @hi_transition ||= 1 + end + end + + a = Hi.new + + # Try to run out of shapes + o = Object.new + i = 0 + while RubyVM::Shape.shapes_available > 0 + o.instance_variable_set(:"@i#{i}", 1) + i += 1 + end + + assert_equal 1,a.transition + assert_equal 1,a.transition + end; + end + def test_run_out_of_shape_instance_variable_defined assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |