summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-17 01:10:14 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-17 01:10:14 +0000
commit347e8c440ad0ee0a219852685f77ba07feddce5c (patch)
tree335ce653584a644bb41cd6c3463789a1c07d3bae /test
parent24eff272f19cd5d3c7a5930fade84bd9a040d2e5 (diff)
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
Diffstat (limited to 'test')
-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 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)