summaryrefslogtreecommitdiff
path: root/test/drb
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-31 16:19:42 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-31 16:19:42 +0000
commit6763ac5552107c4c713f7e60861e00c14f1d3cdd (patch)
tree09ede0b649f50b1b53326739bafc019d70cb0c47 /test/drb
parent832e2b98f9b59c41fa8feea6d6831958623a20b6 (diff)
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/trunk@8872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/drb')
-rw-r--r--test/drb/drbtest.rb24
-rw-r--r--test/drb/ut_drb.rb13
2 files changed, 34 insertions, 3 deletions
diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb
index 432c7a7..410a33c 100644
--- a/test/drb/drbtest.rb
+++ b/test/drb/drbtest.rb
@@ -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
diff --git a/test/drb/ut_drb.rb b/test/drb/ut_drb.rb
index 93ac1d8..f5720cf 100644
--- a/test/drb/ut_drb.rb
+++ b/test/drb/ut_drb.rb
@@ -126,10 +126,23 @@ class DRbEx
[self]
end
+ def method_missing(msg, *a, &b)
+ if msg == :missing
+ return true
+ else
+ super(msg, *a, &b)
+ end
+ end
+
private
def call_private_method
true
end
+
+ protected
+ def call_protected_method
+ true
+ end
end
if __FILE__ == $0