* ext/date/date_core.c: use simple/complex mode instead of light/right mode.

* test/date/*.rb: followed the above changes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2011-05-31 13:28:48 +00:00
Родитель 3b3cf8753d
Коммит 899d2c14b0
6 изменённых файлов: 3758 добавлений и 5503 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Tue May 31 22:24:39 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c: use simple/complex mode instead of light/right mode.
* test/date/*.rb: followed the above changes.
Tue May 31 21:28:33 2011 Tanaka Akira <akr@fsij.org>
* test/ruby/test_signal.rb (TestSignal#test_signal_requiring):

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -623,7 +623,7 @@ static int
parse_time_cb(VALUE m, VALUE hash)
{
static const char pat_source[] =
"\\A(\\d+)h?"
"\\A(\\d+)h?"
"(?:\\s*:?\\s*(\\d+)m?"
"(?:"
"\\s*:?\\s*(\\d+)(?:[,.](\\d+))?s?"

Просмотреть файл

@ -67,9 +67,6 @@ class TestDateNew < Test::Unit::TestCase
end
def test_ordinal__ex
assert_raise(ArgumentError) do
Date.ordinal(2001,1.1)
end
assert_raise(ArgumentError) do
Date.ordinal(2001,366)
end
@ -129,9 +126,6 @@ class TestDateNew < Test::Unit::TestCase
end
def test_civil__ex
assert_raise(ArgumentError) do
Date.civil(2001,2,1.1)
end
assert_raise(ArgumentError) do
Date.civil(2001,2,29)
end
@ -199,9 +193,6 @@ class TestDateNew < Test::Unit::TestCase
end
def test_commercial__ex
assert_raise(ArgumentError) do
Date.commercial(1997,1,1.1)
end
assert_raise(ArgumentError) do
Date.commercial(1997,53,1)
end

Просмотреть файл

@ -184,8 +184,12 @@ class TestDateStrftime < Test::Unit::TestCase
s = '2006-08-08T23:15:33'
(-24..24).collect{|x| '%+.2d' % x}.each do |hh|
%w(00 30).each do |mm|
r = hh + mm
if r[-4,4] == '2430'
r = '+0000'
end
d = DateTime.parse(s + hh + mm)
assert_equal(hh + mm, d.strftime('%z'))
assert_equal(r, d.strftime('%z'))
end
end
end

Просмотреть файл

@ -235,6 +235,116 @@ class TestSH < Test::Unit::TestCase
assert_equal(false, Date.new(2001,2,3) === Rational('4903886/2'))
end
def test_period
# -5000
d = Date.new(-5000,1,1)
assert_equal([-5000, 1, 1, 5], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5001, 11, 22, 5], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.new(-5000,1,1,Date::JULIAN)
assert_equal([-5000, 1, 1, 5], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5001, 11, 22, 5], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.new(-5000,1,1,Date::GREGORIAN)
assert_equal([-5000, 1, 1, 3], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([-5000, 2, 10, 3], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(-105192)
assert_equal([-5000, 1, 1, 5], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5001, 11, 22, 5], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(-105192,Date::JULIAN)
assert_equal([-5000, 1, 1, 5], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5001, 11, 22, 5], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(-105152,Date::GREGORIAN)
assert_equal([-5000, 1, 1, 3], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([-5000, 2, 10, 3], [d2.year, d2.mon, d2.mday, d.wday])
# -5000000
d = Date.new(-5_000_000,1,1)
assert_equal([-5_000_000, 1, 1, 3], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5_000_103, 4, 28, 3], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.new(-5_000_000,1,1,Date::JULIAN)
assert_equal([-5_000_000, 1, 1, 3], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5_000_103, 4, 28, 3], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.new(-5_000_000,1,1,Date::GREGORIAN)
assert_equal([-5_000_000, 1, 1, 6], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([-4_999_898, 9, 4, 6], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(-1824528942)
assert_equal([-5_000_000, 1, 1, 3], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5_000_103, 4, 28, 3], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(-1824528942,Date::JULIAN)
assert_equal([-5_000_000, 1, 1, 3], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([-5_000_103, 4, 28, 3], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(-1824491440,Date::GREGORIAN)
assert_equal([-5_000_000, 1, 1, 6], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([-4_999_898, 9, 4, 6], [d2.year, d2.mon, d2.mday, d.wday])
# 5000000
d = Date.new(5_000_000,1,1)
assert_equal([5_000_000, 1, 1, 6], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([4_999_897, 5, 3, 6], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.new(5_000_000,1,1,Date::JULIAN)
assert_equal([5_000_000, 1, 1, 5], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([5_000_102, 9, 1, 5], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.new(5_000_000,1,1,Date::GREGORIAN)
assert_equal([5_000_000, 1, 1, 6], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([4_999_897, 5, 3, 6], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(1827933560)
assert_equal([5_000_000, 1, 1, 6], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([4_999_897, 5, 3, 6], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(1827971058,Date::JULIAN)
assert_equal([5_000_000, 1, 1, 5], [d.year, d.mon, d.mday, d.wday])
d2 = d.gregorian
assert_equal([5_000_102, 9, 1, 5], [d2.year, d2.mon, d2.mday, d.wday])
d = Date.jd(1827933560,Date::GREGORIAN)
assert_equal([5_000_000, 1, 1, 6], [d.year, d.mon, d.mday, d.wday])
d2 = d.julian
assert_equal([4_999_897, 5, 3, 6], [d2.year, d2.mon, d2.mday, d.wday])
# dt
d = DateTime.new(-123456789,2,3,4,5,6,0)
assert_equal([-123456789, 2, 3, 4, 5, 6, 1],
[d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.wday])
d2 = d.gregorian
assert_equal([-123459325, 12, 27, 4, 5, 6, 1],
[d2.year, d2.mon, d2.mday, d2.hour, d2.min, d2.sec, d.wday])
d = DateTime.new(123456789,2,3,4,5,6,0)
assert_equal([123456789, 2, 3, 4, 5, 6, 5],
[d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.wday])
d2 = d.julian
assert_equal([123454254, 1, 19, 4, 5, 6, 5],
[d2.year, d2.mon, d2.mday, d2.hour, d2.min, d2.sec, d.wday])
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)
@ -245,11 +355,6 @@ class TestSH < Test::Unit::TestCase
assert_equal(DateTime.new(2001,2,3,4,5,6,Rational(9,24),Date::GREGORIAN), d)
end
def test_base
skip unless defined?(Date.test_all)
assert_equal(true, Date.test_all)
end
def test_taint
h = Date._strptime('15:43+09:00', '%R%z')
assert_equal(false, h[:zone].tainted?)
@ -277,4 +382,23 @@ class TestSH < Test::Unit::TestCase
assert_equal(true, s.tainted?)
end
def test_dup
d = Date.new(2001,2,3)
d2 = d.dup
assert_not_equal(d.object_id, d2.object_id)
assert_kind_of(Date, d2)
assert_equal(d, d2)
d = DateTime.new(2001,2,3)
d2 = d.dup
assert_not_equal(d.object_id, d2.object_id)
assert_kind_of(DateTime, d2)
assert_equal(d, d2)
end
def test_base
skip unless defined?(Date.test_all)
assert_equal(true, Date.test_all)
end
end