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

ruby-changes:19477

From: yugui <ko1@a...>
Date: Thu, 12 May 2011 06:26:52 +0900 (JST)
Subject: [ruby-changes:19477] Ruby:r31516 (ruby_1_9_2): merges r30856 from trunk into ruby_1_9_2.

yugui	2011-05-12 06:23:47 +0900 (Thu, 12 May 2011)

  New Revision: 31516

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

  Log:
    merges r30856 from trunk into ruby_1_9_2.
    --
    * lib/date.rb (Date#===): [ruby-core:35127]
    --
    * test/date/test_date.rb (TestDate#test_coerce):
      test for [ruby-core:35127].

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/lib/date/delta.rb
    branches/ruby_1_9_2/lib/date.rb
    branches/ruby_1_9_2/test/date/test_date.rb
    branches/ruby_1_9_2/version.h

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 31515)
+++ ruby_1_9_2/ChangeLog	(revision 31516)
@@ -1,3 +1,12 @@
+Tue May  3 18:23:57 2011  Yuki Sonoda (Yugui)  <yugui@y...>
+
+	* test/date/test_date.rb (TestDate#test_coerce):
+	  test for [ruby-core:35127].
+
+Sun Feb 13 00:48:47 2011  Tadayoshi Funaba  <tadf@d...>
+
+	* lib/date.rb (Date#===): [ruby-core:35127]
+
 Fri Feb 11 19:45:26 2011  Nobuyoshi Nakada  <nobu@r...>
 
 	* eval.c (ruby_cleanup): use rb_ary_free to free internal object.
Index: ruby_1_9_2/lib/date/delta.rb
===================================================================
--- ruby_1_9_2/lib/date/delta.rb	(revision 31515)
+++ ruby_1_9_2/lib/date/delta.rb	(revision 31516)
@@ -231,7 +231,7 @@
 	  @delta.real / (u * RUNITS['#{k}'])
 	end
       end;
-    end
+    end # <<dummy
 
     alias_method :in_mins, :in_minutes
     alias_method :in_secs, :in_seconds
Index: ruby_1_9_2/lib/date.rb
===================================================================
--- ruby_1_9_2/lib/date.rb	(revision 31515)
+++ ruby_1_9_2/lib/date.rb	(revision 31516)
@@ -1,7 +1,7 @@
 #
 # date.rb - date and time library
 #
-# Author: Tadayoshi Funaba 1998-2010
+# Author: Tadayoshi Funaba 1998-2011
 #
 # Documentation: William Webber <william@w...>
 #
@@ -1110,7 +1110,7 @@
 	  end
 	end;
       end
-    end
+    end # <<dummy
 
     private :once
 
@@ -1392,8 +1392,11 @@
     when Numeric; return jd == other
     when Date;    return jd == other.jd
     else
-      l, r = other.coerce(self)
-      return l === r
+      begin
+	l, r = other.coerce(self)
+	return l === r
+      rescue NoMethodError
+      end
     end
     false
   end
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 31515)
+++ ruby_1_9_2/version.h	(revision 31516)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 200
+#define RUBY_PATCHLEVEL 201
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_2/test/date/test_date.rb
===================================================================
--- ruby_1_9_2/test/date/test_date.rb	(revision 31515)
+++ ruby_1_9_2/test/date/test_date.rb	(revision 31516)
@@ -113,6 +113,27 @@
     assert_equal(d2, dt2)
   end
 
+  def test_coerce
+    bug4375 = '[ruby-core:35127]'
+    d = Date.jd(0)
+    d2 = Date.jd(1)
+    others = [1, d2, Date::Infinity.new, nil, Object.new]
+    assert_nothing_raised(bug4375) {
+      others.each do |o|
+        case o
+        when d
+          flunk("expected not to match")
+        end
+      end
+    }
+    assert_nothing_raised(bug4375) {
+      case d
+      when *others
+        flunk("expected not to match")
+      end
+    }
+  end
+
   def test_hash
     h = {}
     h[Date.new(1999,5,23)] = 0

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

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