summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--lib/date.rb11
-rw-r--r--lib/date/delta.rb2
-rw-r--r--test/date/test_date.rb21
-rw-r--r--version.h2
5 files changed, 39 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index ba6e2dc4a6..bc2f4b34eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/version.h b/version.h
index fa1e1b86bf..ab9e96dfaf 100644
--- a/version.h
+++ b/version.h
@@ -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