summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHaldun Bayhantopcu <haldun@github.com>2023-02-15 21:13:54 +0100
committerAaron Patterson <aaron.patterson@gmail.com>2023-02-15 15:43:46 -0800
commit0b4b2cd1ee161f2875375181e0978d7757e25c8a (patch)
treef071ac7815fcc526c3698b9aa5954f8b7d2b54be /test
parent70d84a5f3deab5caaeb88134e9d90b1dca4a0462 (diff)
Fix removing ivars from clases and modules.
Co-authored-by: Adam Hess <hparker@github.com>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7314
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_shapes.rb26
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;