summaryrefslogtreecommitdiff
path: root/test/ruby/test_shapes.rb
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-10-31 16:38:05 -0400
committerPeter Zhu <[email protected]>2023-10-31 16:38:05 -0400
commit8889992b75f85c8080fc09c7a3a1cb6123a098c1 (patch)
tree878ff46f9cf87dd5707644690ef748f563f75751 /test/ruby/test_shapes.rb
parentb7a3e2e71dc68ec56036f37ab5a1f94489436f96 (diff)
Fix remove_instance_variable for too complex class
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r--test/ruby/test_shapes.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb
index a098edf409..529964729b 100644
--- a/test/ruby/test_shapes.rb
+++ b/test/ruby/test_shapes.rb
@@ -233,7 +233,7 @@ class TestShapes < Test::Unit::TestCase
end;
end
- def test_run_out_of_shape
+ def test_run_out_of_shape_for_object
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class A
@@ -252,6 +252,23 @@ class TestShapes < Test::Unit::TestCase
end;
end
+ def test_run_out_of_shape_for_class
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ c = Class.new
+ i = 0
+ while RubyVM::Shape.shapes_available > 0
+ c.instance_variable_set(:"@i#{i}", 1)
+ i += 1
+ end
+
+ c.instance_variable_set(:@a, 1)
+ assert_equal(1, c.instance_variable_get(:@a))
+ c.remove_instance_variable(:@a)
+ assert_nil(c.instance_variable_get(:@a))
+ end;
+ end
+
def test_run_out_of_shape_generic_ivar_set
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;