summaryrefslogtreecommitdiff
path: root/test/date
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-13 14:52:27 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-13 14:52:27 +0000
commite931e27addcd3ff13aca8014f65265fc0a1126d2 (patch)
tree18770b98958d28c292bc623e5446581e0ba60ea2 /test/date
parentad22d67e2b3f35c540c6794cb343024bca694544 (diff)
merge revision(s) 41077,41105: [Backport #8485] [Backport #8500] [Backport #8578]
* ext/date/date_core.c: fixed a bug [ruby-core:55295]. reported by Riley Lynch. * ext/date/date_core.c: fixed coding error [ruby-core:55337]. reported by Riley Lynch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/date')
-rw-r--r--test/date/test_switch_hitter.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb
index f16c7983a0..f18d76b393 100644
--- a/test/date/test_switch_hitter.rb
+++ b/test/date/test_switch_hitter.rb
@@ -474,6 +474,59 @@ class TestSH < Test::Unit::TestCase
period2_iter(+cm_period * (1 << 64) - 3, +cm_period * (1 << 64) + 3)
end
+ def test_different_alignments
+ assert_equal(0, Date.jd(0) <=> Date.civil(-4713, 11, 24, Date::GREGORIAN))
+ assert_equal(0, Date.jd(213447717) <=> Date.civil(579687, 11, 24))
+ assert_equal(0, Date.jd(-213447717) <=> Date.civil(-589113, 11, 24, Date::GREGORIAN))
+
+ assert_equal(0, Date.jd(0) <=> DateTime.civil(-4713, 11, 24, 0, 0, 0, 0, Date::GREGORIAN))
+ assert_equal(0, Date.jd(213447717) <=> DateTime.civil(579687, 11, 24))
+ assert_equal(0, Date.jd(-213447717) <=> DateTime.civil(-589113, 11, 24, 0, 0, 0, 0, Date::GREGORIAN))
+
+ assert(Date.jd(0) == Date.civil(-4713, 11, 24, Date::GREGORIAN))
+ assert(Date.jd(213447717) == Date.civil(579687, 11, 24))
+ assert(Date.jd(-213447717) == Date.civil(-589113, 11, 24, Date::GREGORIAN))
+
+ assert(Date.jd(0) == DateTime.civil(-4713, 11, 24, 0, 0, 0, 0, Date::GREGORIAN))
+ assert(Date.jd(213447717) == DateTime.civil(579687, 11, 24))
+ assert(Date.jd(-213447717) == DateTime.civil(-589113, 11, 24, 0, 0, 0, 0, Date::GREGORIAN))
+
+ assert(Date.jd(0) === Date.civil(-4713, 11, 24, Date::GREGORIAN))
+ assert(Date.jd(213447717) === Date.civil(579687, 11, 24))
+ assert(Date.jd(-213447717) === Date.civil(-589113, 11, 24, Date::GREGORIAN))
+
+ assert(Date.jd(0) === DateTime.civil(-4713, 11, 24, 12, 0, 0, 0, Date::GREGORIAN))
+ assert(Date.jd(213447717) === DateTime.civil(579687, 11, 24, 12))
+ assert(Date.jd(-213447717) === DateTime.civil(-589113, 11, 24, 12, 0, 0, 0, Date::GREGORIAN))
+
+ a = Date.jd(0)
+ b = Date.civil(-4713, 11, 24, Date::GREGORIAN)
+ assert_equal(0, a <=> b)
+
+ a = Date.civil(-4712, 1, 1, Date::JULIAN)
+ b = Date.civil(-4713, 11, 24, Date::GREGORIAN)
+ a.jd; b.jd
+ assert_equal(0, a <=> b)
+
+ a = Date.jd(0)
+ b = Date.civil(-4713, 11, 24, Date::GREGORIAN)
+ assert(a == b)
+
+ a = Date.civil(-4712, 1, 1, Date::JULIAN)
+ b = Date.civil(-4713, 11, 24, Date::GREGORIAN)
+ a.jd; b.jd
+ assert(a == b)
+
+ a = Date.jd(0)
+ b = Date.civil(-4713, 11, 24, Date::GREGORIAN)
+ assert(a === b)
+
+ a = Date.civil(-4712, 1, 1, Date::JULIAN)
+ b = Date.civil(-4713, 11, 24, Date::GREGORIAN)
+ a.jd; b.jd
+ assert(a === b)
+ end
+
def test_marshal14
s = "\x04\x03u:\x01\x04Date\x01\v\x04\x03[\x01\x02i\x03\xE8i%T"
d = Marshal.load(s)