summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-22 05:27:47 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-22 06:09:30 +0900
commit520dcbd6009b07458d67309ae33a602d77062975 (patch)
tree13d96cb2df62c2d10cbe4316d77429e4b01d4294 /test
parentd0e4ccbefcdd6032d0ae70bc54c9a4fb55d92576 (diff)
reset cache before iterating
cee02d754d76563635c1db90d2ab6c01f8492470 resets pCMC and `me` will be a invalidated and continuing the invalidated `me`, it will break the data structure. This patch tris to clear all methods of specified class before manipulating the `me`s. [Issue #17417]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3964
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb32
1 files changed, 26 insertions, 6 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index b27a176889..c364de46e4 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -2441,12 +2441,6 @@ class TestRefinement < Test::Unit::TestCase
$VERBOSE = verbose_bak
end
- private
-
- def eval_using(mod, s)
- eval("using #{mod}; #{s}", Sandbox::BINDING)
- end
-
# [Bug #17386]
def test_prepended_with_method_cache
foo = Class.new do
@@ -2473,4 +2467,30 @@ class TestRefinement < Test::Unit::TestCase
foo.prepend code
assert_equal :Code, obj.foo
end
+
+ # [Bug #17417]
+ def test_prepended_with_method_cache_17417
+ assert_normal_exit %q{
+ module M
+ def hoge; end
+ end
+
+ module R
+ refine Hash do
+ def except *args; end
+ end
+ end
+
+ h = {}
+ h.method(:except) # put it on pCMC
+ Hash.prepend(M)
+ h.method(:except)
+ }
+ end
+
+ private
+
+ def eval_using(mod, s)
+ eval("using #{mod}; #{s}", Sandbox::BINDING)
+ end
end