diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-26 16:02:25 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-26 16:02:25 +0000 |
commit | 9fe4a35e67e46b84049e6c3951f4720d550322cf (patch) | |
tree | 3d04c4b80b1b5f5a30937b473f8cc00ca0a8ea08 /test/date | |
parent | 0b98b9a95dc3bdedd620ccaf015607a5a959a06e (diff) | |
download | ruby-9fe4a35e67e46b84049e6c3951f4720d550322cf.tar.gz |
* ext/date/date_core.c: modified validation methods.
* ext/date/lib/date.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/date')
-rw-r--r-- | test/date/test_date_attr.rb | 1 | ||||
-rw-r--r-- | test/date/test_date_base.rb | 49 | ||||
-rw-r--r-- | test/date/test_date_new.rb | 2 |
3 files changed, 27 insertions, 25 deletions
diff --git a/test/date/test_date_attr.rb b/test/date/test_date_attr.rb index 9224dc1340..88a54d7461 100644 --- a/test/date/test_date_attr.rb +++ b/test/date/test_date_attr.rb @@ -96,6 +96,7 @@ class TestDateAttr < Test::Unit::TestCase end def test_nth_kday + skip unless Date.new.respond_to?(:nth_kday?, true) assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, 1,0)) assert_equal(true, Date.new(2001,1,14).__send__(:nth_kday?, 2,0)) assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, 3,0)) diff --git a/test/date/test_date_base.rb b/test/date/test_date_base.rb index c4639633be..9f76bac8a3 100644 --- a/test/date/test_date_base.rb +++ b/test/date/test_date_base.rb @@ -53,9 +53,7 @@ class TestDateBase < Test::Unit::TestCase end def test_ordinal__julian - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from..@to m, d, y = julian_from_absolute(absolute_from_julian_day_number(j)) j0 = julian_day_number_from_absolute(absolute_from_julian(12, 31, y - 1)) @@ -70,9 +68,7 @@ class TestDateBase < Test::Unit::TestCase end def test_ordinal__gregorian - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from..@to m, d, y = gregorian_from_absolute(absolute_from_julian_day_number(j)) j0 = @@ -88,9 +84,7 @@ class TestDateBase < Test::Unit::TestCase end def test_civil__julian - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from..@to m, d, y = julian_from_absolute(absolute_from_julian_day_number(j)) j2 = julian_day_number_from_absolute(absolute_from_julian(m, d, y)) @@ -105,9 +99,7 @@ class TestDateBase < Test::Unit::TestCase end def test_civil__gregorian - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from..@to m, d, y = gregorian_from_absolute(absolute_from_julian_day_number(j)) j2 = julian_day_number_from_absolute(absolute_from_gregorian(m, d, y)) @@ -122,9 +114,7 @@ class TestDateBase < Test::Unit::TestCase end def test_commercial__gregorian - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from..@to w, d, y = iso_from_absolute(absolute_from_julian_day_number(j)) j2 = julian_day_number_from_absolute(absolute_from_iso(w, d, y)) @@ -139,9 +129,7 @@ class TestDateBase < Test::Unit::TestCase end def test_weeknum - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from..@to for k in 0..1 wy, ww, wd = Date.__send__(:jd_to_weeknum, j, k, Date::GREGORIAN) @@ -152,9 +140,7 @@ class TestDateBase < Test::Unit::TestCase end def test_weeknum__2 - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) for j in @from4t..@to4t d = Date.jd(j) t = Time.mktime(d.year, d.mon, d.mday) @@ -172,9 +158,9 @@ class TestDateBase < Test::Unit::TestCase end def test_nth_kday - unless defined?(Calendar) - return - end + skip unless defined?(Calendar) + skip unless (Date.respond_to?(:nth_kday_to_jd, true) && + Date.respond_to?(:jd_to_nth_kday, true)) for y in 1601..2401 for m in 1..12 for n in -5..5 @@ -194,7 +180,7 @@ class TestDateBase < Test::Unit::TestCase end def test_jd - assert_equal(1<<33, Date.jd(1<<33).jd) + assert_equal(1 << 33, Date.jd(1 << 33).jd) end def test_mjd @@ -235,6 +221,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_jd valid_jd_p = :_valid_jd? + skip unless Date.respond_to?(valid_jd_p, true) assert_equal(-1, Date.__send__(valid_jd_p, -1)) assert_equal(0, Date.__send__(valid_jd_p, 0)) assert_equal(1, Date.__send__(valid_jd_p, 1)) @@ -243,6 +230,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_ordinal valid_ordinal_p = :_valid_ordinal? + skip unless Date.respond_to?(valid_ordinal_p, true) assert_nil(Date.__send__(valid_ordinal_p, 1999,366)) assert_equal(2451910, Date.__send__(valid_ordinal_p, 2000,366)) assert_nil(Date.__send__(valid_ordinal_p, 1999,-366)) @@ -257,6 +245,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_ordinal__edge valid_ordinal_p = :_valid_ordinal? + skip unless Date.respond_to?(valid_ordinal_p, true) (1601..2400).each do |y| d = if Date.leap?(y) then 366 else 365 end assert_not_nil(Date.__send__(valid_ordinal_p, y,d)) @@ -282,6 +271,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_ordinal__italy valid_ordinal_p = :_valid_ordinal? + skip unless Date.respond_to?(valid_ordinal_p, true) (1..355).each do |d| assert_not_nil(Date.__send__(valid_ordinal_p, 1582,d,Date::ITALY)) end @@ -298,6 +288,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_ordinal__england valid_ordinal_p = :_valid_ordinal? + skip unless Date.respond_to?(valid_ordinal_p, true) (1..355).each do |d| assert_not_nil(Date.__send__(valid_ordinal_p, 1752,d,Date::ENGLAND)) end @@ -308,6 +299,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_civil valid_civil_p = :_valid_civil? + skip unless Date.respond_to?(valid_civil_p, true) assert_nil(Date.__send__(valid_civil_p, 1999,2,29)) assert_equal(2451604, Date.__send__(valid_civil_p, 2000,2,29)) assert_nil(Date.__send__(valid_civil_p, 1999,2,-29)) @@ -323,6 +315,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_civil__edge valid_civil_p = :_valid_civil? + skip unless Date.respond_to?(valid_civil_p, true) (1601..2400).each do |y| d = if Date.leap?(y) then 29 else 28 end assert_not_nil(Date.__send__(valid_civil_p, y,2,d)) @@ -341,6 +334,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_civil__italy valid_civil_p = :_valid_civil? + skip unless Date.respond_to?(valid_civil_p, true) (1..4).each do |d| assert_not_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY)) end @@ -369,6 +363,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_civil__england valid_civil_p = :_valid_civil? + skip unless Date.respond_to?(valid_civil_p, true) (1..2).each do |d| assert_not_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND)) end @@ -391,6 +386,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_commercial valid_commercial_p = :_valid_commercial? + skip unless Date.respond_to?(valid_commercial_p, true) assert_nil(Date.__send__(valid_commercial_p, 1999,53,1)) assert_equal(2453367, Date.__send__(valid_commercial_p, 2004,53,1)) assert_nil(Date.__send__(valid_commercial_p, 1999,-53,-1)) @@ -400,6 +396,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_weeknum valid_weeknum_p = :_valid_weeknum? + skip unless Date.respond_to?(valid_weeknum_p, true) assert_nil(Date.__send__(valid_weeknum_p, 1999,53,0, 0)) assert_equal(2454101, Date.__send__(valid_weeknum_p, 2006,53,0, 0)) assert_nil(Date.__send__(valid_weeknum_p, 1999,-53,-1, 0)) @@ -414,6 +411,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_nth_kday valid_nth_kday_p = :_valid_nth_kday? + skip unless Date.respond_to?(valid_nth_kday_p, true) assert_nil(Date.__send__(valid_nth_kday_p, 1992,2, 5,0)) assert_equal(2448682, Date.__send__(valid_nth_kday_p, 1992,2, 5,6)) assert_equal(2448682, Date.__send__(valid_nth_kday_p, 1992,2, 5,-1)) @@ -423,6 +421,7 @@ class TestDateBase < Test::Unit::TestCase def test_valid_time valid_time_p = :_valid_time? + skip unless Date.respond_to?(valid_time_p, true) assert_equal(Rational(0), DateTime.__send__(valid_time_p, 0,0,0)) assert_nil(DateTime.__send__(valid_time_p, 25,59,59)) assert_nil(DateTime.__send__(valid_time_p, 23,60,59)) diff --git a/test/date/test_date_new.rb b/test/date/test_date_new.rb index 14ff247294..da63c2248e 100644 --- a/test/date/test_date_new.rb +++ b/test/date/test_date_new.rb @@ -211,6 +211,7 @@ class TestDateNew < Test::Unit::TestCase end def test_weeknum + skip unless Date.respond_to?(:weeknum, true) d = Date.__send__(:weeknum) dt = DateTime.__send__(:weeknum) assert_equal([-4712, 1, 1], [d.year, d.mon, d.mday]) @@ -233,6 +234,7 @@ class TestDateNew < Test::Unit::TestCase end def test_nth_kday + skip unless Date.respond_to?(:nth_kday, true) d = Date.__send__(:nth_kday) dt = DateTime.__send__(:nth_kday) assert_equal([-4712, 1, 1], [d.year, d.mon, d.mday]) |