mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/date/test_switch_hitter.rb: added a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
51a0501a39
commit
a252c17e15
2 changed files with 38 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Jun 26 23:49:21 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* test/date/test_switch_hitter.rb: added a test.
|
||||||
|
|
||||||
Sun Jun 26 22:21:23 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
Sun Jun 26 22:21:23 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* ext/date/date_core.c: refactoring.
|
* ext/date/date_core.c: refactoring.
|
||||||
|
|
|
@ -360,6 +360,40 @@ class TestSH < Test::Unit::TestCase
|
||||||
[d2.year, d2.mon, d2.mday, d2.hour, d2.min, d2.sec, d.wday])
|
[d2.year, d2.mon, d2.mday, d2.hour, d2.min, d2.sec, d.wday])
|
||||||
end
|
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
|
def test_marshal
|
||||||
s = "\x04\bU:\tDate[\bU:\rRational[\ai\x03\xCF\xD3Ji\ai\x00o:\x13Date::Infinity\x06:\a@di\xFA"
|
s = "\x04\bU:\tDate[\bU:\rRational[\ai\x03\xCF\xD3Ji\ai\x00o:\x13Date::Infinity\x06:\a@di\xFA"
|
||||||
d = Marshal.load(s)
|
d = Marshal.load(s)
|
||||||
|
|
Loading…
Reference in a new issue