aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_method.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-24 07:28:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-24 07:28:11 +0000
commit1fc33199736f316dd71d0c551edbf514528ddde6 (patch)
tree41f04b811f87b4439d37b2cd365fda59147ed5ac /test/ruby/test_method.rb
parent3c0cbea874a38ee233cae86e1dd854f00d5d6b00 (diff)
downloadruby-1fc33199736f316dd71d0c551edbf514528ddde6.tar.gz
proc.c: make method by define_method public
* proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [ruby-core:57747] [Bug #9005] [ruby-core:58497] [Bug #9141] * vm.c (rb_vm_cref_in_context): return ruby level cref if self is same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_method.rb')
-rw-r--r--test/ruby/test_method.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 2fde505183..5b7c76da4d 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -338,6 +338,29 @@ class TestMethod < Test::Unit::TestCase
assert_equal(true, m.private_method_defined?(:foo))
end
+ def test_define_method_in_private_scope
+ bug9005 = '[ruby-core:57747] [Bug #9005]'
+ c = Class.new
+ class << c
+ public :define_method
+ end
+ TOPLEVEL_BINDING.eval("proc{|c|c.define_method(:x) {|*x|throw x}}").call(c)
+ o = c.new
+ assert_throw(bug9005) {o.x(bug9005)}
+ end
+
+ def test_singleton_define_method_in_private_scope
+ bug9141 = '[ruby-core:58497] [Bug #9141]'
+ o = Object.new
+ class << o
+ public :define_singleton_method
+ end
+ TOPLEVEL_BINDING.eval("proc{|o|o.define_singleton_method(:x) {|x|throw x}}").call(o)
+ assert_throw(bug9141) do
+ o.x(bug9141)
+ end
+ end
+
def test_super_in_proc_from_define_method
c1 = Class.new {
def m