diff options
Diffstat (limited to 'test')
-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; |