summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-15 06:53:01 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-15 06:53:01 +0000
commitab530f056c7e45aa711a736790fb448bbdce19e7 (patch)
tree6a9dac707d66a270d1f720ad3c7134073677da87 /test
parentb64a3e41202c86e5eaa410fe182b3dfdb2b0dc4c (diff)
merge revision(s) r44931: [Backport #9452]
* vm_insnhelper.c (vm_call_method): should check ci->me->flag of a refining method in case the method is private. [ruby-core:60111] [Bug #9452] * vm_method.c (make_method_entry_refined): set me->flag of a refined method entry to NOEX_PUBLIC in case the original method is private and it is refined as a public method. The original flag is stored in me->def->body.orig_me, so it's OK to make a refined method entry public. [ruby-core:60111] [Bug #9452] * test/ruby/test_refinement.rb: related tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 2110221fc1..417059f651 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -955,6 +955,53 @@ class TestRefinement < Test::Unit::TestCase
INPUT
end
+ def test_adding_private_method
+ bug9452 = '[ruby-core:60111] [Bug #9452]'
+
+ assert_in_out_err([], <<-INPUT, ["Success!", "NoMethodError"], [], bug9452)
+ $VERBOSE = nil #to suppress warning "Refinements are experimental, ..."
+ module R
+ refine Object do
+ def m
+ puts "Success!"
+ end
+
+ private(:m)
+ end
+ end
+
+ using R
+
+ m
+ 42.m rescue p($!.class)
+ INPUT
+ end
+
+ def test_making_private_method_public
+ bug9452 = '[ruby-core:60111] [Bug #9452]'
+
+ assert_in_out_err([], <<-INPUT, ["Success!", "Success!"], [], bug9452)
+ $VERBOSE = nil #to suppress warning "Refinements are experimental, ..."
+ class Object
+ private
+ def m
+ end
+ end
+
+ module R
+ refine Object do
+ def m
+ puts "Success!"
+ end
+ end
+ end
+
+ using R
+ m
+ 42.m
+ INPUT
+ end
+
private
def eval_using(mod, s)