[前][次][番号順一覧][スレッド一覧]

ruby-changes:48302

From: nobu <ko1@a...>
Date: Wed, 25 Oct 2017 14:23:59 +0900 (JST)
Subject: [ruby-changes:48302] nobu:r60416 (trunk): range.c: use rb_check_funcall

nobu	2017-10-25 14:23:54 +0900 (Wed, 25 Oct 2017)

  New Revision: 60416

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60416

  Log:
    range.c: use rb_check_funcall
    
    * range.c (rb_range_values): use rb_check_funcall instead of
      calling rb_respond_to then rb_funcall, and allow `begin` and
      `end` to be private as well as other internal conversions.
      [ruby-core:83541] [Bug #14048]

  Modified files:
    trunk/range.c
    trunk/test/ruby/test_range.rb
Index: range.c
===================================================================
--- range.c	(revision 60415)
+++ range.c	(revision 60416)
@@ -988,18 +988,10 @@ rb_range_values(VALUE range, VALUE *begp https://github.com/ruby/ruby/blob/trunk/range.c#L988
     }
     else {
 	VALUE x;
-#if 0
-	/* TODO: fix spec/mspec/lib/mspec/mocks/mock.rb:Mock.verify_call */
 	b = rb_check_funcall(range, id_beg, 0, 0);
 	if (b == Qundef) return (int)Qfalse;
 	e = rb_check_funcall(range, id_end, 0, 0);
 	if (e == Qundef) return (int)Qfalse;
-#else
-	if (!rb_respond_to(range, id_beg)) return (int)Qfalse;
-	if (!rb_respond_to(range, id_end)) return (int)Qfalse;
-	b = rb_funcall(range, id_beg, 0);
-	e = rb_funcall(range, id_end, 0);
-#endif
 	x = rb_check_funcall(range, rb_intern("exclude_end?"), 0, 0);
 	if (x == Qundef) return (int)Qfalse;
 	excl = RTEST(x);
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb	(revision 60415)
+++ test/ruby/test_range.rb	(revision 60416)
@@ -393,6 +393,9 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L393
     o.exclude_end = false
     assert_nil([0][o])
     assert_raise(RangeError) { [0][o] = 1 }
+    class << o
+      private :begin, :end
+    end
     o.begin = 10
     o.end = 10
     assert_nil([0][o])

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]