summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHParker <HParker@github.com>2023-02-17 08:15:03 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2023-03-09 15:34:49 -0800
commit69465df4242f3b2d8e55fbe18d7c45b47b40a626 (patch)
tree57aad5e76cfff0615df51443ede9b010d1c4f2f4 /test
parent65a95b82593683ba2e566fe1d14b086b80874c92 (diff)
Allow classes and modules to become too complex
This makes the behavior of classes and modules when there are too many instance variables match the behavior of objects with too many instance variables.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7349
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_shapes.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb
index b1a2ba2f1b..e34256415b 100644
--- a/test/ruby/test_shapes.rb
+++ b/test/ruby/test_shapes.rb
@@ -105,7 +105,27 @@ class TestShapes < Test::Unit::TestCase
obj.instance_variable_set(:"@a#{_1}", 1)
end
- assert_false RubyVM::Shape.of(obj).too_complex?
+ assert_predicate RubyVM::Shape.of(obj), :too_complex?
+ end
+
+ def test_too_many_ivs_on_module
+ obj = Module.new
+
+ (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 1).times do
+ obj.instance_variable_set(:"@a#{_1}", 1)
+ end
+
+ assert_predicate RubyVM::Shape.of(obj), :too_complex?
+ end
+
+ def test_too_many_ivs_on_builtin
+ obj = "string"
+
+ (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 1).times do
+ obj.instance_variable_set(:"@a#{_1}", 1)
+ end
+
+ refute RubyVM::Shape.of(obj).too_complex?
end
def test_removing_when_too_many_ivs_on_class