diff options
author | Jean Boussier <[email protected]> | 2023-11-03 10:42:20 +0100 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2023-11-03 11:52:17 +0100 |
commit | 35da6f864a05624433be2c8059b87d30b899b370 (patch) | |
tree | 5e493a6b652a53923408e1f7feff514d08372259 /test/ruby/test_shapes.rb | |
parent | 1f1b9b0942ec12dde1af8000f8cb84692904fccc (diff) |
rb_ivar_defined: handle complex modules
It was assuming only objects can be complex.
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 4967b404e2..1135daecbe 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -345,6 +345,45 @@ class TestShapes < Test::Unit::TestCase end; end + def test_run_out_of_shape_instance_variable_defined + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class A + attr_reader :a, :b, :c, :d + def initialize + @a = @b = @c = @d = 1 + end + end + + o = Object.new + i = 0 + while RubyVM::Shape.shapes_available > 0 + o.instance_variable_set(:"@i#{i}", 1) + i += 1 + end + + a = A.new + assert_equal true, a.instance_variable_defined?(:@a) + end; + end + + def test_run_out_of_shape_instance_variable_defined_on_module + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + o = Object.new + i = 0 + while RubyVM::Shape.shapes_available > 0 + o.instance_variable_set(:"@i#{i}", 1) + i += 1 + end + + module A + @a = @b = @c = @d = 1 + end + + assert_equal true, A.instance_variable_defined?(:@a) + end; + end def test_run_out_of_shape_remove_instance_variable assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |