From 347e8c440ad0ee0a219852685f77ba07feddce5c Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 17 Jul 2013 01:10:14 +0000 Subject: merge revision(s) 41077,41105: [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_1_9_3@42015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/date/test_switch_hitter.rb | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'test') diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb index 8431d40a29..be3346fd5a 100644 --- a/test/date/test_switch_hitter.rb +++ b/test/date/test_switch_hitter.rb @@ -472,6 +472,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_marshal s = "\x04\bU:\tDate[\bU:\rRational[\ai\x03\xCF\xD3Ji\ai\x00o:\x13Date::Infinity\x06:\a@di\xFA" d = Marshal.load(s) -- cgit v1.2.3