diff options
author | Peter Zhu <[email protected]> | 2023-11-01 13:13:51 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-11-01 13:13:51 -0400 |
commit | bdf8ce807ffe8e4bfd2947aba809855857b958ed (patch) | |
tree | e89236074653b79cf47b66831e9d88531eea3331 /test/ruby/test_shapes.rb | |
parent | 90b21b864d7ec32c048731393f5ebe89a3b9024a (diff) |
Fix remove_class_variable for too complex classes
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 5e77dc049e..11eb66e7a3 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -252,7 +252,7 @@ class TestShapes < Test::Unit::TestCase end; end - def test_run_out_of_shape_for_class + def test_run_out_of_shape_for_class_ivar assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; i = 0 @@ -275,6 +275,28 @@ class TestShapes < Test::Unit::TestCase end; end + def test_run_out_of_shape_for_class_cvar + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + c = Class.new + i = 0 + while RubyVM::Shape.shapes_available > 0 + c.class_variable_set(:"@@i#{i}", 1) + i += 1 + end + + c.class_variable_set(:@@a, 1) + assert_equal(1, c.class_variable_get(:@@a)) + + c.class_eval { remove_class_variable(:@@a) } + assert_false(c.class_variable_defined?(:@@a)) + + assert_raise(NameError) do + c.class_eval { remove_class_variable(:@@a) } + end + end; + end + def test_run_out_of_shape_generic_ivar_set assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |