use private_methods and protected_methods instead of respond_to? to check

method visibility. [ruby-dev:26616]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
seki 2005-07-31 16:19:42 +00:00
parent 846a9c902f
commit 711b655f38
4 changed files with 56 additions and 16 deletions

View file

@ -176,24 +176,42 @@ module DRbCore
end
end
def test_07_public_private
def test_07_public_private_protected_missing
assert_nothing_raised() {
begin
@there.method_missing(:eval)
rescue NameError
rescue NoMethodError
assert_match(/^private method \`eval\'/, $!.message)
end
}
assert_nothing_raised() {
begin
@there.call_private_method
rescue NoMethodError
assert_equal(NoMethodError, $!.class)
assert_match(/^private method \`call_private_method\'/, $!.message)
end
}
assert_nothing_raised() {
begin
@there.call_protected_method
rescue NoMethodError
assert_equal(NoMethodError, $!.class)
assert_match(/^protected method \`call_protected_method\'/, $!.message)
end
}
assert_nothing_raised() {
begin
@there.method_missing(:undefined_method_test)
rescue NameError
rescue NoMethodError
assert_equal(NoMethodError, $!.class)
assert_match(/^undefined method \`undefined_method_test\'/, $!.message)
end
}
assert_raises(SecurityError) do
@there.method_missing(:__send__, :to_s)
end
assert_equal(true, @there.missing)
end
def test_08_here