diff options
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/date_ext_test.rb | 1 | ||||
-rw-r--r-- | activesupport/test/core_ext/date_time_ext_test.rb | 1 | ||||
-rw-r--r-- | activesupport/test/core_ext/numeric_ext_test.rb | 9 | ||||
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 2 |
4 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 8863e6a07f..4ec595d918 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -121,6 +121,7 @@ class DateExtCalculationsTest < Test::Unit::TestCase assert_equal Date.new(2005,6,28), Date.new(2005,2,28).advance(:months => 4) assert_equal Date.new(2012,9,28), Date.new(2005,2,28).advance(:years => 7, :months => 7) assert_equal Date.new(2013,10,3), Date.new(2005,2,28).advance(:years => 7, :months => 19, :days => 5) + assert_equal Date.new(2005,2,28), Date.new(2004,2,29).advance(:years => 1) #leap day plus one year end def test_next_week diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index 81e05a9f49..3c79fccdd1 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -163,6 +163,7 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase assert_equal DateTime.civil(2005,6,28,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:months => 4) assert_equal DateTime.civil(2012,9,28,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => 7, :months => 7) assert_equal DateTime.civil(2013,10,3,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :days => 5) + assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10).advance(:years => 1) #leap day plus one year end def test_next_week diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index bbbd706aa1..996b166405 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -80,6 +80,11 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase assert_equal 30.days.to_i.since(@dtnow), 1.month.to_i.since(@dtnow) assert_equal 365.25.days.to_f.since(@dtnow), 1.year.to_f.since(@dtnow) end + + def test_add_one_year_to_leap_day + assert_equal Time.utc(2005,2,28,15,15,10), Time.utc(2004,2,29,15,15,10) + 1.year + assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10) + 1.year + end end class NumericExtDateTest < Test::Unit::TestCase @@ -99,6 +104,10 @@ class NumericExtDateTest < Test::Unit::TestCase assert_equal @today.advance(:days => 2).advance(:months => -3), @today + 2.days - 3.months assert_equal @today.advance(:days => 1).advance(:months => 2), @today + 1.day + 2.months end + + def test_add_one_year_to_leap_day + assert_equal Date.new(2005,2,28), Date.new(2004,2,29) + 1.year + end end class NumericExtSizeTest < Test::Unit::TestCase diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index b390ae2249..8ab84baa5d 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -238,6 +238,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,6,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:months => 4) assert_equal Time.local(2012,9,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 7) assert_equal Time.local(2013,10,3,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :days => 5) + assert_equal Time.local(2005,2,28,15,15,10), Time.local(2004,2,29,15,15,10).advance(:years => 1) #leap day plus one year end def test_utc_plus @@ -245,6 +246,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:months => 4) assert_equal Time.utc(2012,9,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 7, :months => 7) assert_equal Time.utc(2013,10,3,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 7, :months => 19, :days => 11) + assert_equal Time.utc(2005,2,28,15,15,10), Time.utc(2004,2,29,15,15,10).advance(:years => 1) #leap day plus one year end def test_next_week |