зеркало из https://github.com/github/ruby.git
test_object.rb: test for public_send
* test/ruby/test_object.rb (TestObject#test_public_send): add test for public_send. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ce48e9a930
Коммит
cfc2103108
|
@ -563,6 +563,32 @@ class TestObject < Test::Unit::TestCase
|
|||
assert_equal(:ok, x)
|
||||
end
|
||||
|
||||
def test_public_send
|
||||
c = Class.new do
|
||||
def pub
|
||||
:ok
|
||||
end
|
||||
|
||||
def invoke(m)
|
||||
public_send(m)
|
||||
end
|
||||
|
||||
protected
|
||||
def prot
|
||||
:ng
|
||||
end
|
||||
|
||||
private
|
||||
def priv
|
||||
:ng
|
||||
end
|
||||
end.new
|
||||
assert_equal(:ok, c.public_send(:pub))
|
||||
assert_raise(NoMethodError) {c.public_send(:priv)}
|
||||
assert_raise(NoMethodError) {c.public_send(:prot)}
|
||||
assert_raise(NoMethodError) {c.invoke(:priv)}
|
||||
end
|
||||
|
||||
def test_no_superclass_method
|
||||
bug2312 = '[ruby-dev:39581]'
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче