diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-11 21:23:47 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-11 21:23:47 +0000 |
commit | ad558ae184116f7c3806c0f420f0ed6a864f9373 (patch) | |
tree | 5057211a56430eff023a68f99b14892edd13aeff | |
parent | 6a2bd5fcb68568e4b5d8992c0107c7d4338fa958 (diff) |
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].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | lib/date.rb | 11 | ||||
-rw-r--r-- | lib/date/delta.rb | 2 | ||||
-rw-r--r-- | test/date/test_date.rb | 21 | ||||
-rw-r--r-- | version.h | 2 |
5 files changed, 39 insertions, 6 deletions
@@ -1,3 +1,12 @@ +Tue May 3 18:23:57 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp> + + * test/date/test_date.rb (TestDate#test_coerce): + test for [ruby-core:35127]. + +Sun Feb 13 00:48:47 2011 Tadayoshi Funaba <tadf@dotrb.org> + + * lib/date.rb (Date#===): [ruby-core:35127] + Fri Feb 11 19:45:26 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> * eval.c (ruby_cleanup): use rb_ary_free to free internal object. diff --git a/lib/date.rb b/lib/date.rb index e4773ef897..ebbc8b581e 100644 --- a/lib/date.rb +++ b/lib/date.rb @@ -1,7 +1,7 @@ # # date.rb - date and time library # -# Author: Tadayoshi Funaba 1998-2010 +# Author: Tadayoshi Funaba 1998-2011 # # Documentation: William Webber <william@williamwebber.com> # @@ -1110,7 +1110,7 @@ class Date end end; end - end + end # <<dummy private :once @@ -1392,8 +1392,11 @@ class Date 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 diff --git a/lib/date/delta.rb b/lib/date/delta.rb index eacfdefc62..d2ed5e86d3 100644 --- a/lib/date/delta.rb +++ b/lib/date/delta.rb @@ -231,7 +231,7 @@ class Date @delta.real / (u * RUNITS['#{k}']) end end; - end + end # <<dummy alias_method :in_mins, :in_minutes alias_method :in_secs, :in_seconds diff --git a/test/date/test_date.rb b/test/date/test_date.rb index f2be9e24c4..47ce568408 100644 --- a/test/date/test_date.rb +++ b/test/date/test_date.rb @@ -113,6 +113,27 @@ class TestDate < Test::Unit::TestCase 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 @@ -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 |