summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb39
1 files changed, 35 insertions, 4 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 3ca00ed912..380119fb9b 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -379,10 +379,15 @@ class TestRefinement < Test::Unit::TestCase
def test_refine_module_with_overriding
m1 = Module.new {
def foo
- [:m1]
+ super << :m1
end
}
- c = Class.new {
+ c0 = Class.new {
+ def foo
+ [:c0]
+ end
+ }
+ c = Class.new(c0) {
include m1
}
m2 = Module.new {
@@ -393,7 +398,7 @@ class TestRefinement < Test::Unit::TestCase
end
}
obj = c.new
- assert_equal([:m1, :m2], m2.module_eval { obj.foo })
+ assert_equal([:c0, :m1, :m2], m2.module_eval { obj.foo })
end
def test_refine_module_with_double_overriding
@@ -726,7 +731,6 @@ class TestRefinement < Test::Unit::TestCase
end
def test_inline_method_cache
- skip "can't implement efficiently with the current implementation of refinements"
c = InlineMethodCache::C.new
f = Proc.new { c.foo }
assert_equal("original", f.call)
@@ -822,4 +826,31 @@ class TestRefinement < Test::Unit::TestCase
end
end
end
+
+ module RedifineRefinedMethod
+ class C
+ def foo
+ "original"
+ end
+ end
+
+ module M
+ refine C do
+ def foo
+ "refined"
+ end
+ end
+ end
+
+ class C
+ def foo
+ "redefined"
+ end
+ end
+ end
+
+ def test_redefine_refined_method
+ c = RedifineRefinedMethod::C.new
+ assert_equal("refined", RedifineRefinedMethod::M.module_eval { c.foo })
+ end
end