diff options
Diffstat (limited to 'test/date/test_switch_hitter.rb')
-rw-r--r-- | test/date/test_switch_hitter.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb index 4294a21e9d..6b1050d0ca 100644 --- a/test/date/test_switch_hitter.rb +++ b/test/date/test_switch_hitter.rb @@ -360,6 +360,40 @@ class TestSH < Test::Unit::TestCase [d2.year, d2.mon, d2.mday, d2.hour, d2.min, d2.sec, d.wday]) end + def period2_iter2(from, to, sg) + (from..to).each do |j| + d = Date.jd(j, sg) + d2 = Date.new(d.year, d.mon, d.mday, sg) + assert_equal(d2.jd, j) + assert_equal(d2.ajd, d.ajd) + assert_equal(d2.year, d.year) + + d = DateTime.jd(j, 12,0,0, '+12:00', sg) + d2 = DateTime.new(d.year, d.mon, d.mday, + d.hour, d.min, d.sec, d.offset, sg) + assert_equal(d2.jd, j) + assert_equal(d2.ajd, d.ajd) + assert_equal(d2.year, d.year) + end + end + + def period2_iter(from, to) + period2_iter2(from, to, Date::GREGORIAN) + period2_iter2(from, to, Date::ITALY) + period2_iter2(from, to, Date::ENGLAND) + period2_iter2(from, to, Date::JULIAN) + end + + def test_period2 + cm_period0 = 71149239 + cm_period = 0xfffffff.div(cm_period0) * cm_period0 + period2_iter(-cm_period * (1 << 64) - 3, -cm_period * (1 << 64) + 3) + period2_iter(-cm_period - 3, -cm_period + 3) + period2_iter(0 - 3, 0 + 3) + period2_iter(+cm_period - 3, +cm_period + 3) + period2_iter(+cm_period * (1 << 64) - 3, +cm_period * (1 << 64) + 3) + 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) |