aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatherine Oelsner <octokatherine@github.com>2023-10-18 14:09:35 -0700
committerJohn Hawthorn <john@hawthorn.email>2023-10-18 15:01:13 -0700
commit0ac6fb225d15cbcd35b8122b151a17eaa92fafaf (patch)
treed1fae22b9adb7ac7e4568185814ee86d75ba8980
parenta7032b80af18b7f2eb3552c5231ca36a8c69f1be (diff)
downloadruby-0ac6fb225d15cbcd35b8122b151a17eaa92fafaf.tar.gz
Add test for many ivars
Co-authored-by: John Hawthorn <john@hawthorn.email>
-rw-r--r--test/ruby/test_variable.rb12
1 files changed, 12 insertions, 0 deletions
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