From 0ac6fb225d15cbcd35b8122b151a17eaa92fafaf Mon Sep 17 00:00:00 2001 From: Katherine Oelsner Date: Wed, 18 Oct 2023 14:09:35 -0700 Subject: [PATCH] Add test for many ivars Co-authored-by: John Hawthorn --- test/ruby/test_variable.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index e50b681ce8..86f2e4bb84 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -413,6 +413,18 @@ class TestVariable < Test::Unit::TestCase assert_equal(%i(v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11), v, bug11674) end + def test_many_instance_variables + objects = [Object.new, Hash.new, Module.new] + objects.each do |obj| + 1000.times do |i| + obj.instance_variable_set("@var#{i}", i) + end + 1000.times do |i| + assert_equal(i, obj.instance_variable_get("@var#{i}")) + end + end + end + private def with_kwargs_11(v1:, v2:, v3:, v4:, v5:, v6:, v7:, v8:, v9:, v10:, v11:) local_variables