diff options
author | Haldun Bayhantopcu <[email protected]> | 2023-02-15 21:13:54 +0100 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2023-02-15 15:43:46 -0800 |
commit | 0b4b2cd1ee161f2875375181e0978d7757e25c8a (patch) | |
tree | f071ac7815fcc526c3698b9aa5954f8b7d2b54be /test/ruby/test_shapes.rb | |
parent | 70d84a5f3deab5caaeb88134e9d90b1dca4a0462 (diff) |
Fix removing ivars from clases and modules.
Co-authored-by: Adam Hess <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7314
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 85adcd4a80..0e7a2d0b0c 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -108,6 +108,32 @@ class TestShapes < Test::Unit::TestCase assert_false RubyVM::Shape.of(obj).too_complex? end + def test_removing_when_too_many_ivs_on_class + obj = Class.new + + (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + obj.instance_variable_set(:"@a#{_1}", 1) + end + (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + obj.remove_instance_variable(:"@a#{_1}") + end + + assert_empty obj.instance_variables + end + + def test_removing_when_too_many_ivs_on_module + obj = Module.new + + (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + obj.instance_variable_set(:"@a#{_1}", 1) + end + (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + obj.remove_instance_variable(:"@a#{_1}") + end + + assert_empty obj.instance_variables + end + def test_too_complex_ractor assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |