summaryrefslogtreecommitdiff
path: root/test/ruby/test_object_id.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_object_id.rb')
-rw-r--r--test/ruby/test_object_id.rb57
1 files changed, 53 insertions, 4 deletions
diff --git a/test/ruby/test_object_id.rb b/test/ruby/test_object_id.rb
index 24434f8aba..034674e5be 100644
--- a/test/ruby/test_object_id.rb
+++ b/test/ruby/test_object_id.rb
@@ -140,7 +140,7 @@ end
class TestObjectIdTooComplex < TestObjectId
class TooComplex
def initialize
- @too_complex_obj_id_test = 1
+ @complex_obj_id_test = 1
end
end
@@ -155,7 +155,7 @@ class TestObjectIdTooComplex < TestObjectId
@obj.instance_variable_set("@a#{rand(10_000)}", 1)
if defined?(RubyVM::Shape)
- assert_predicate(RubyVM::Shape.of(@obj), :too_complex?)
+ assert_predicate(RubyVM::Shape.of(@obj), :complex?)
end
end
end
@@ -181,7 +181,7 @@ class TestObjectIdTooComplexClass < TestObjectId
@obj.instance_variable_set("@test", 1)
if defined?(RubyVM::Shape)
- assert_predicate(RubyVM::Shape.of(@obj), :too_complex?)
+ assert_predicate(RubyVM::Shape.of(@obj), :complex?)
end
end
end
@@ -202,7 +202,7 @@ class TestObjectIdTooComplexGeneric < TestObjectId
@obj.instance_variable_set("@a#{rand(10_000)}", 1)
if defined?(RubyVM::Shape)
- assert_predicate(RubyVM::Shape.of(@obj), :too_complex?)
+ assert_predicate(RubyVM::Shape.of(@obj), :complex?)
end
end
end
@@ -252,3 +252,52 @@ class TestObjectIdRactor < Test::Unit::TestCase
end;
end
end
+
+class TestObjectIdStruct < TestObjectId
+ EmbeddedStruct = Struct.new(:embedded_field)
+
+ def setup
+ @obj = EmbeddedStruct.new
+ end
+end
+
+class TestObjectIdStructGenIvar < TestObjectId
+ GenIvarStruct = Struct.new(:a, :b, :c)
+
+ def setup
+ @obj = GenIvarStruct.new
+ end
+end
+
+class TestObjectIdStructNotEmbed < TestObjectId
+ MANY_IVS = 80
+
+ StructNotEmbed = Struct.new(*MANY_IVS.times.map { |i| :"field_#{i}" })
+
+ def setup
+ @obj = StructNotEmbed.new
+ end
+end
+
+class TestObjectIdStructTooComplex < TestObjectId
+ StructTooComplex = Struct.new(:a) do
+ def initialize
+ @complex_obj_id_test = 1
+ end
+ end
+
+ def setup
+ if defined?(RubyVM::Shape::SHAPE_MAX_VARIATIONS)
+ assert_equal 8, RubyVM::Shape::SHAPE_MAX_VARIATIONS
+ end
+ 8.times do |i|
+ StructTooComplex.new.instance_variable_set("@TestObjectIdStructTooComplex#{i}", 1)
+ end
+ @obj = StructTooComplex.new
+ @obj.instance_variable_set("@a#{rand(10_000)}", 1)
+
+ if defined?(RubyVM::Shape)
+ assert_predicate(RubyVM::Shape.of(@obj), :complex?)
+ end
+ end
+end