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

ruby-changes:38500

From: usa <ko1@a...>
Date: Thu, 21 May 2015 14:06:23 +0900 (JST)
Subject: [ruby-changes:38500] usa:r50581 (ruby_2_1): merge revision(s) 50421: [Backport #11113]

usa	2015-05-21 14:05:56 +0900 (Thu, 21 May 2015)

  New Revision: 50581

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

  Log:
    merge revision(s) 50421: [Backport #11113]
    
    * range.c (linear_object_p, range_include): test if covered for
      linear objects.  [ruby-core:69052] [Bug #11113]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/range.c
    branches/ruby_2_1/test/ruby/test_range.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 50580)
+++ ruby_2_1/ChangeLog	(revision 50581)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu May 21 14:04:06 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* range.c (linear_object_p, range_include): test if covered for
+	  linear objects.  [ruby-core:69052] [Bug #11113]
+
 Thu May 21 14:01:40 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* rational.c: Added documentation for rational literal.
Index: ruby_2_1/range.c
===================================================================
--- ruby_2_1/range.c	(revision 50580)
+++ ruby_2_1/range.c	(revision 50581)
@@ -329,6 +329,21 @@ discrete_object_p(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/range.c#L329
     return rb_respond_to(obj, id_succ);
 }
 
+static int
+linear_object_p(VALUE obj)
+{
+    if (FIXNUM_P(obj) || FLONUM_P(obj)) return TRUE;
+    if (SPECIAL_CONST_P(obj)) return FALSE;
+    switch (BUILTIN_TYPE(obj)) {
+      case T_FLOAT:
+      case T_BIGNUM:
+	return TRUE;
+    }
+    if (rb_obj_is_kind_of(obj, rb_cNumeric)) return TRUE;
+    if (rb_obj_is_kind_of(obj, rb_cTime)) return TRUE;
+    return FALSE;
+}
+
 static VALUE
 range_step_size(VALUE range, VALUE args, VALUE eobj)
 {
@@ -1148,8 +1163,7 @@ range_include(VALUE range, VALUE val) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/range.c#L1163
     VALUE beg = RANGE_BEG(range);
     VALUE end = RANGE_END(range);
     int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
-	     rb_obj_is_kind_of(beg, rb_cNumeric) ||
-	     rb_obj_is_kind_of(end, rb_cNumeric);
+	     linear_object_p(beg) || linear_object_p(end);
 
     if (nv ||
 	!NIL_P(rb_check_to_integer(beg, "to_int")) ||
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 50580)
+++ ruby_2_1/version.h	(revision 50581)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.7"
 #define RUBY_RELEASE_DATE "2015-05-21"
-#define RUBY_PATCHLEVEL 353
+#define RUBY_PATCHLEVEL 354
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 5
Index: ruby_2_1/test/ruby/test_range.rb
===================================================================
--- ruby_2_1/test/ruby/test_range.rb	(revision 50580)
+++ ruby_2_1/test/ruby/test_range.rb	(revision 50581)
@@ -278,6 +278,14 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_range.rb#L278
     assert_not_operator(0..10, :===, 11)
   end
 
+  def test_eqq_time
+    bug11113 = '[ruby-core:69052] [Bug #11113]'
+    t = Time.now
+    assert_nothing_raised(TypeError, bug11113) {
+      assert_operator(t..(t+10), :===, t+5)
+    }
+  end
+
   def test_include
     assert_include("a".."z", "c")
     assert_not_include("a".."z", "5")

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r50421


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

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