diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-05-11 18:47:22 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2025-05-11 19:35:58 +0200 |
| commit | f2e5f6dbb605960b69ddced5503a18639aa29e8e (patch) | |
| tree | c321822a9ce48b8ce78b8e343e0d6eb1f9fd61b9 /test/ruby | |
| parent | 54c2edc05d8cc3fff25f04e4b28e698b9324e163 (diff) | |
Allow T_CLASS and generic types to be too_complex
The intial complex shape implementation never allowed objects
other than T_OBJECT to become too complex, unless we run out of
shapes.
I don't see any reason to prevent that.
Ref: https://github.com/ruby/ruby/pull/6931
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13301
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_object_id.rb | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/test/ruby/test_object_id.rb b/test/ruby/test_object_id.rb index 3543802990..2277bba634 100644 --- a/test/ruby/test_object_id.rb +++ b/test/ruby/test_object_id.rb @@ -137,10 +137,14 @@ class TestObjectIdTooComplex < TestObjectId assert_equal 8, RubyVM::Shape::SHAPE_MAX_VARIATIONS end 8.times do |i| - TooComplex.new.instance_variable_set("@a#{i}", 1) + TooComplex.new.instance_variable_set("@TestObjectIdTooComplex#{i}", 1) end @obj = TooComplex.new - @obj.instance_variable_set(:@test, 1) + @obj.instance_variable_set("@a#{rand(10_000)}", 1) + + if defined?(RubyVM::Shape) + assert_predicate(RubyVM::Shape.of(@obj), :too_complex?) + end end end @@ -152,11 +156,21 @@ class TestObjectIdTooComplexClass < TestObjectId if defined?(RubyVM::Shape::SHAPE_MAX_VARIATIONS) assert_equal 8, RubyVM::Shape::SHAPE_MAX_VARIATIONS end + + @obj = TooComplex.new + + @obj.instance_variable_set("@___#{rand(100_000)}", 1) + 8.times do |i| - TooComplex.new.instance_variable_set("@a#{i}", 1) + @obj.instance_variable_set("@TestObjectIdTooComplexClass#{i}", 1) + @obj.remove_instance_variable("@TestObjectIdTooComplexClass#{i}") + end + + @obj.instance_variable_set("@___#{rand(100_000)}", 1) + + if defined?(RubyVM::Shape) + assert_predicate(RubyVM::Shape.of(@obj), :too_complex?) end - @obj = TooComplex.new - @obj.instance_variable_set(:@test, 1) end end @@ -169,9 +183,14 @@ class TestObjectIdTooComplexGeneric < TestObjectId assert_equal 8, RubyVM::Shape::SHAPE_MAX_VARIATIONS end 8.times do |i| - TooComplex.new.instance_variable_set("@a#{i}", 1) + TooComplex.new.instance_variable_set("@TestObjectIdTooComplexGeneric#{i}", 1) end @obj = TooComplex.new - @obj.instance_variable_set(:@test, 1) + @obj.instance_variable_set("@a#{rand(10_000)}", 1) + @obj.instance_variable_set("@a#{rand(10_000)}", 1) + + if defined?(RubyVM::Shape) + assert_predicate(RubyVM::Shape.of(@obj), :too_complex?) + end end end |
