summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2023-02-08 15:27:28 -0500
committernagachika <nagachika@ruby-lang.org>2023-07-01 14:17:30 +0900
commit06dae46036316e6e9926c4613ac8058b78eb7f2e (patch)
tree4c98aee46dfe22db1d389ce416df0ed361306b53 /test/ruby
parent814271b2f7e20dd3da13f30a2fdc823c720110ac (diff)
Copy cvar table on clone
When a class with a class variable is cloned we need to also copy the cvar cache table from the original table to the clone. I found this bug while working on fixing [Bug #19379]. While this does not fix that bug directly it is still a required change to fix another bug revealed by the fix in https://github.com/ruby/ruby/pull/7265 This needs to be backported to 3.2.x and 3.1.x. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_variable.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index 9acba39f40..4fe80a86c8 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -33,6 +33,12 @@ class TestVariable < Test::Unit::TestCase
end
end
+ Athena = Gods.clone
+
+ def test_cloned_classes_copy_cvar_cache
+ assert_equal "Cronus", Athena.new.ruler0
+ end
+
def test_setting_class_variable_on_module_through_inheritance
mod = Module.new
mod.class_variable_set(:@@foo, 1)