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:
nobu 2012-12-05 16:07:27 +00:00
Родитель ce48e9a930
Коммит cfc2103108
1 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -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]'