summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-04 05:30:08 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-04 05:30:08 +0000
commit1f8b6187955332e212b0c2c073c7965d44c389e0 (patch)
tree8b5310a18e9f1a27914264a8940d368ac5b4c13d
parentbb16543ac77a4372877d0f9f3809c9400fe4cb70 (diff)
downloadruby-1f8b6187955332e212b0c2c073c7965d44c389e0.tar.gz
ruby-1f8b6187955332e212b0c2c073c7965d44c389e0.tar.xz
ruby-1f8b6187955332e212b0c2c073c7965d44c389e0.zip
* eval.c (rb_obj_respond_to): check the result of respond_to? method
by RTEST. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c2
-rw-r--r--test/ruby/test_string.rb8
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index cf88c30aa..addbbf30b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/eval.c b/eval.c
index ab2c33dbc..e5c8d47fe 100644
--- a/eval.c
+++ b/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));
}
}
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index c71be7d09..70214c8ff 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -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