ruby-changes:4791
From: ko1@a...
Date: Sun, 4 May 2008 14:30:25 +0900 (JST)
Subject: [ruby-changes:4791] akr - Ruby:r16285 (trunk): * eval.c (rb_obj_respond_to): check the result of respond_to? method
akr 2008-05-04 14:30:08 +0900 (Sun, 04 May 2008)
New Revision: 16285
Modified files:
trunk/ChangeLog
trunk/eval.c
trunk/test/ruby/test_string.rb
Log:
* eval.c (rb_obj_respond_to): check the result of respond_to? method
by RTEST.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_string.rb?r1=16285&r2=16284&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16285&r2=16284&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval.c?r1=16285&r2=16284&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 16284)
+++ ChangeLog (revision 16285)
@@ -1,3 +1,8 @@
+Sun May 4 14:29:14 2008 Tanaka Akira <akr@f...>
+
+ * 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@f...>
* string.c (rb_str_each_line): return original string.
Index: eval.c
===================================================================
--- eval.c (revision 16284)
+++ eval.c (revision 16285)
@@ -454,7 +454,7 @@
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));
}
}
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb (revision 16284)
+++ test/ruby/test_string.rb (revision 16285)
@@ -1403,4 +1403,12 @@
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
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/