summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 06:55:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 06:55:36 +0000
commit1ded4dbd110868891d1255bc11845c1130a0ca3e (patch)
tree6b65267c4722e6645143f66e572931fcd1661513
parentc3a750ebee3960f5ee47bcba4e60d8c3585eb843 (diff)
* test/ruby/test_object.rb: tests that respond_to? returns false.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_object.rb12
-rw-r--r--vm_eval.c6
3 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 70805ddc73..0829b3a9a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Aug 5 15:55:33 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * test/ruby/test_object.rb: tests that respond_to? returns false.
+
Fri Aug 5 13:32:43 2011 Shugo Maeda <shugo@ruby-lang.org>
* lib/xmlrpc/client.rb, lib/xmlrpc/server.rb: should use
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index b23a8e6498..4ce422f7b5 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -181,18 +181,30 @@ class TestObject < Test::Unit::TestCase
o = Object.new
def o.to_s; 1; end
assert_raise(TypeError) { String(o) }
+ def o.to_s; "o"; end
+ assert_equal("o", String(o))
+ def o.respond_to?(*) false; end
+ assert_raise(TypeError) { String(o) }
end
def test_check_convert_type
o = Object.new
def o.to_a; 1; end
assert_raise(TypeError) { Array(o) }
+ def o.to_a; [1]; end
+ assert_equal([1], Array(o))
+ def o.respond_to?(*) false; end
+ assert_equal([o], Array(o))
end
def test_to_integer
o = Object.new
def o.to_i; nil; end
assert_raise(TypeError) { Integer(o) }
+ def o.to_i; 42; end
+ assert_equal(42, Integer(o))
+ def o.respond_to?(*) false; end
+ assert_raise(TypeError) { Integer(o) }
end
class MyInteger
diff --git a/vm_eval.c b/vm_eval.c
index e7ff24f7d3..241356cd73 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -265,10 +265,12 @@ check_funcall_failed(struct rescue_funcall_args *args, VALUE e)
static VALUE
check_funcall(VALUE recv, ID mid, int argc, VALUE *argv)
{
- const rb_method_entry_t *me = rb_method_entry(CLASS_OF(recv), idRespond_to);
+ VALUE klass = CLASS_OF(recv);
+ const rb_method_entry_t *me;
rb_thread_t *th = GET_THREAD();
int call_status;
+ me = rb_method_entry(klass, idRespond_to);
if (me && !(me->flag & NOEX_BASIC)) {
VALUE args[2] = {ID2SYM(mid), Qtrue};
if (!RTEST(vm_call0(th, recv, idRespond_to, 2, args, me))) {
@@ -279,7 +281,7 @@ check_funcall(VALUE recv, ID mid, int argc, VALUE *argv)
me = rb_search_method_entry(recv, mid);
call_status = rb_method_call_status(th, me, CALL_FCALL, Qundef);
if (call_status != NOEX_OK) {
- if (rb_method_basic_definition_p(CLASS_OF(recv), idMethodMissing)) {
+ if (rb_method_basic_definition_p(klass, idMethodMissing)) {
return Qundef;
}
else {