summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-16 07:01:44 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-16 07:01:44 +0000
commit3dc8a69df7617377bbece579c6e1abf87df85299 (patch)
treec10d10e15a8be1091f2a66dd8cc1d33f25076c27 /test/ruby
parent98cf9c43fa18bf0874af47b9d1b4933981ea456d (diff)
* vm_insnhelper.c (vm_call_method): protected singleton methods of
an object should not be able to called from other instances of the class of the object. [ruby-core:26761] * vm_eval.c (rb_method_call_status): ditto. * test/ruby/test_module.rb (test_protected_singleton_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_module.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 59c965325f..92b2f7b561 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -854,4 +854,28 @@ class TestModule < Test::Unit::TestCase
end
assert_equal("", stderr)
end
+
+ def test_protected_singleton_method
+ klass = Class.new
+ x = klass.new
+ class << x
+ protected
+
+ def foo
+ end
+ end
+ assert_raise(NoMethodError) do
+ x.foo
+ end
+ klass.send(:define_method, :bar) do
+ x.foo
+ end
+ assert_nothing_raised do
+ x.bar
+ end
+ y = klass.new
+ assert_raise(NoMethodError) do
+ y.bar
+ end
+ end
end