зеркало из https://github.com/github/ruby.git
* eval.c (rb_obj_respond_to): check the result of respond_to? method
by RTEST. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7ef9aba753
Коммит
f587eab23c
|
@ -1,3 +1,8 @@
|
|||
Sun May 4 14:29:14 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* eval.c (rb_obj_respond_to): check the result of respond_to? method
|
||||
by RTEST.
|
||||
|
||||
Sun May 4 12:57:58 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (rb_str_each_line): return original string.
|
||||
|
|
2
eval.c
2
eval.c
|
@ -454,7 +454,7 @@ rb_obj_respond_to(VALUE obj, ID id, int priv)
|
|||
args[n++] = ID2SYM(id);
|
||||
if (priv)
|
||||
args[n++] = Qtrue;
|
||||
return rb_funcall2(obj, respond_to, n, args);
|
||||
return RTEST(rb_funcall2(obj, respond_to, n, args));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1403,4 +1403,12 @@ class TestString < Test::Unit::TestCase
|
|||
s1 << 'a'
|
||||
}
|
||||
end
|
||||
|
||||
def test_respond_to
|
||||
o = Object.new
|
||||
def o.respond_to?(arg) [:to_str].include?(arg) ? nil : super end
|
||||
def o.to_str() "" end
|
||||
def o.==(other) "" == other end
|
||||
assert_equal(false, "" == o)
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче