1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_method.c (rb_method_boundp): respond_to?(:protected_method,

true) should return true.  Pointed out by Marc-Andre Lafortune.
  [ruby-dev:41837]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2010-07-07 04:06:32 +00:00
parent 2520f3f79c
commit 42f4a548f0
3 changed files with 28 additions and 14 deletions

View file

@ -1,3 +1,9 @@
Wed Jul 7 13:02:59 2010 Akinori MUSHA <knu@iDaemons.org>
* vm_method.c (rb_method_boundp): respond_to?(:protected_method,
true) should return true. Pointed out by Marc-Andre Lafortune.
[ruby-dev:41837]
Wed Jul 7 12:00:24 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (ruby_find_basename): should initialize f.

View file

@ -366,13 +366,17 @@ class TestMethod < Test::Unit::TestCase
assert_equal('method', defined?(mv3))
assert_equal('method', defined?(self.mv1))
assert_equal(nil, defined?(self.mv2))
assert_equal(nil, defined?(self.mv2))
assert_equal('method', defined?(self.mv3))
assert_equal(true, respond_to?(:mv1))
assert_equal(false, respond_to?(:mv2))
assert_equal(false, respond_to?(:mv3))
assert_equal(true, respond_to?(:mv1, true))
assert_equal(true, respond_to?(:mv2, true))
assert_equal(true, respond_to?(:mv3, true))
assert_nothing_raised { mv1 }
assert_nothing_raised { mv2 }
assert_nothing_raised { mv3 }
@ -384,13 +388,17 @@ class TestMethod < Test::Unit::TestCase
v = Visibility.new
assert_equal('method', defined?(v.mv1))
assert_equal(nil, defined?(v.mv2))
assert_equal(nil, defined?(v.mv3))
assert_equal(nil, defined?(v.mv2))
assert_equal(nil, defined?(v.mv3))
assert_equal(true, v.respond_to?(:mv1))
assert_equal(false, v.respond_to?(:mv2))
assert_equal(false, v.respond_to?(:mv3))
assert_equal(true, v.respond_to?(:mv1, true))
assert_equal(true, v.respond_to?(:mv2, true))
assert_equal(true, v.respond_to?(:mv3, true))
assert_nothing_raised { v.mv1 }
assert_raise(NoMethodError) { v.mv2 }
assert_raise(NoMethodError) { v.mv3 }

View file

@ -565,19 +565,19 @@ rb_method_boundp(VALUE klass, ID id, int ex)
{
rb_method_entry_t *me = rb_method_entry(klass, id);
if (me != 0) {
if ((ex & NOEX_RESPONDS) && (me->flag & NOEX_PROTECTED) ||
(ex & ~NOEX_RESPONDS) && (me->flag & NOEX_PRIVATE)) {
return 0;
if (!me) return 0;
if (ex & ~NOEX_RESPONDS) { /* pub */
if (me->flag & NOEX_PRIVATE) return 0;
if (ex & NOEX_RESPONDS) {
if (me->flag & NOEX_PROTECTED) return 0;
}
if (!me->def) return 0;
if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
if (ex & NOEX_RESPONDS) return 2;
return 0;
}
return 1;
}
return 0;
if (!me->def) return 0;
if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
if (ex & NOEX_RESPONDS) return 2;
return 0;
}
return 1;
}
void