summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-11 04:45:31 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-11 04:45:31 +0000
commitb0c8aeeb9caa9b796892c30f6c675cc2191e89b5 (patch)
tree7118094dc9ed0f20e6e901ca922a41bfc943307c /test
parentfc4b6cd25f231d19851cd256b7c0ad1fe06000d9 (diff)
* eval.c (rb_using_refinement, rb_mod_using, f_using): clear method
cache only when using is called explicitly. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 12a00bb16c..450a308839 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestRefinement < Test::Unit::TestCase
class Foo
@@ -709,4 +710,72 @@ class TestRefinement < Test::Unit::TestCase
assert_equal("refined", InlineMethodCache::M.module_eval(&f))
assert_equal("original", f.call)
end
+
+ module UsingMethodCache
+ class C
+ def foo
+ "original"
+ end
+ end
+
+ module M1
+ refine C do
+ def foo
+ "M1"
+ end
+ end
+ end
+
+ module M2
+ refine C do
+ def foo
+ "M2"
+ end
+ end
+ end
+
+ module M
+ c = C.new
+ ORIGINAL_FOO = c.foo
+ using M1
+ c.foo
+ using M2
+ M2_FOO = c.foo
+ end
+ end
+
+ def test_using_method_cache
+ assert_equal("original", UsingMethodCache::M::ORIGINAL_FOO)
+ assert_equal("M2", UsingMethodCache::M::M2_FOO)
+
+ assert_in_out_err([], <<-INPUT, %w(:M1 :M2), [])
+ class C
+ def foo
+ "original"
+ end
+ end
+
+ module M1
+ refine C do
+ def foo
+ :M1
+ end
+ end
+ end
+
+ module M2
+ refine C do
+ def foo
+ :M2
+ end
+ end
+ end
+
+ c = C.new
+ using M1
+ p c.foo
+ using M2
+ p c.foo
+ INPUT
+ end
end