From 71234daef1517cf190adfc5978e56882d2a57ea6 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 8 Jul 2006 18:14:49 +0000 Subject: r4487@asus: jeremy | 2006-04-29 12:21:39 -0700 Check whether @flash is defined? for warnings-safety. r4488@asus: jeremy | 2006-04-29 12:23:15 -0700 Check whether @flash is defined? for warnings-safety. Obviates nil? check. r4489@asus: jeremy | 2006-04-29 12:45:18 -0700 Check whether @session is defined? for warnings-safety. r4490@asus: jeremy | 2006-04-29 12:50:41 -0700 Check whether @rendering_runtime is defined? for warnings-safety. r4491@asus: jeremy | 2006-04-29 12:55:01 -0700 Check whether @_cycles is defined? for warnings-safety. r4492@asus: jeremy | 2006-04-29 12:59:19 -0700 Check whether instance variables are defined? for warnings-safety. r4493@asus: jeremy | 2006-04-29 13:14:09 -0700 Add nil @template to PrototypeHelperTest to suppress unitialized instance variable warning. r4494@asus: jeremy | 2006-04-29 13:31:34 -0700 Check whether @auto_index defined? for warnings-safety. r4495@asus: jeremy | 2006-04-29 13:32:24 -0700 Wrap content_columns redefinitions with silence_warnings. r4496@asus: jeremy | 2006-04-29 13:35:28 -0700 Wrap more redefinitions with silence_warnings. r4829@asus: jeremy | 2006-07-08 10:59:20 -0700 abstract unit, fix warnings r4830@asus: jeremy | 2006-07-08 11:06:12 -0700 Use parens to silence warning. r4831@asus: jeremy | 2006-07-08 11:06:48 -0700 Use parens to silence warning. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4595 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/time_ext_test.rb | 46 +++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'activesupport/test/core_ext/time_ext_test.rb') diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index dee0a1f84e..ab76348967 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -1,6 +1,4 @@ -require 'test/unit' -require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/numeric' -require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/time' +require File.dirname(__FILE__) + '/../abstract_unit' class TimeExtCalculationsTest < Test::Unit::TestCase def test_seconds_since_midnight @@ -19,35 +17,35 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,11,28), Time.local(2005,12,01,0,0,0).beginning_of_week #thursday assert_equal Time.local(2005,11,28), Time.local(2005,12,02,0,0,0).beginning_of_week #friday assert_equal Time.local(2005,11,28), Time.local(2005,12,03,0,0,0).beginning_of_week #saturday - assert_equal Time.local(2005,11,28), Time.local(2005,12,04,0,0,0).beginning_of_week #sunday + assert_equal Time.local(2005,11,28), Time.local(2005,12,04,0,0,0).beginning_of_week #sunday end - + def test_beginning_of_day assert_equal Time.local(2005,2,4,0,0,0), Time.local(2005,2,4,10,10,10).beginning_of_day end - + def test_beginning_of_month assert_equal Time.local(2005,2,1,0,0,0), Time.local(2005,2,22,10,10,10).beginning_of_month end - + def test_beginning_of_quarter assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,2,15,10,10,10).beginning_of_quarter assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,1,1,0,0,0).beginning_of_quarter assert_equal Time.local(2005,10,1,0,0,0), Time.local(2005,12,31,10,10,10).beginning_of_quarter assert_equal Time.local(2005,4,1,0,0,0), Time.local(2005,6,30,23,59,59).beginning_of_quarter end - + def test_end_of_month assert_equal Time.local(2005,3,31,0,0,0), Time.local(2005,3,20,10,10,10).end_of_month assert_equal Time.local(2005,2,28,0,0,0), Time.local(2005,2,20,10,10,10).end_of_month assert_equal Time.local(2005,4,30,0,0,0), Time.local(2005,4,20,10,10,10).end_of_month - + end - + def test_beginning_of_year assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,2,22,10,10,10).beginning_of_year end - + def test_months_ago assert_equal Time.local(2005,5,5,10), Time.local(2005,6,5,10,0,0).months_ago(1) assert_equal Time.local(2004,11,5,10), Time.local(2005,6,5,10,0,0).months_ago(7) @@ -65,31 +63,31 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).months_since(12) assert_equal Time.local(2007,6,5,10), Time.local(2005,6,5,10,0,0).months_since(24) end - + def test_years_ago assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).years_ago(1) assert_equal Time.local(1998,6,5,10), Time.local(2005,6,5,10,0,0).years_ago(7) end - + def test_years_since assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).years_since(1) assert_equal Time.local(2012,6,5,10), Time.local(2005,6,5,10,0,0).years_since(7) # Failure because of size limitations of numeric? - # assert_equal Time.local(2182,6,5,10), Time.local(2005,6,5,10,0,0).years_since(177) + # assert_equal Time.local(2182,6,5,10), Time.local(2005,6,5,10,0,0).years_since(177) end def test_last_year assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).last_year end - + def test_ago assert_equal Time.local(2005,2,22,10,10,9), Time.local(2005,2,22,10,10,10).ago(1) assert_equal Time.local(2005,2,22,9,10,10), Time.local(2005,2,22,10,10,10).ago(3600) assert_equal Time.local(2005,2,20,10,10,10), Time.local(2005,2,22,10,10,10).ago(86400*2) assert_equal Time.local(2005,2,20,9,9,45), Time.local(2005,2,22,10,10,10).ago(86400*2 + 3600 + 25) - end - + end + def test_since assert_equal Time.local(2005,2,22,10,10,11), Time.local(2005,2,22,10,10,10).since(1) assert_equal Time.local(2005,2,22,11,10,10), Time.local(2005,2,22,10,10,10).since(3600) @@ -101,12 +99,12 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,2,21,10,10,10), Time.local(2005,2,22,10,10,10).yesterday assert_equal Time.local(2005,2,28,10,10,10), Time.local(2005,3,2,10,10,10).yesterday.yesterday end - + def test_tomorrow assert_equal Time.local(2005,2,23,10,10,10), Time.local(2005,2,22,10,10,10).tomorrow assert_equal Time.local(2005,3,2,10,10,10), Time.local(2005,2,28,10,10,10).tomorrow.tomorrow end - + def test_change assert_equal Time.local(2006,2,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:year => 2006) assert_equal Time.local(2005,6,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:month => 6) @@ -120,7 +118,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,1,2,11,22, 7, 0), Time.local(2005,1,2,11,22,33,44).change(:sec => 7) assert_equal Time.local(2005,1,2,11,22,33, 8), Time.local(2005,1,2,11,22,33,44).change(:usec => 8) end - + def test_utc_change assert_equal Time.utc(2006,2,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:year => 2006) assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:month => 6) @@ -136,7 +134,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase 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) end - + def test_utc_plus assert_equal Time.utc(2006,2,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 1) assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:months => 4) @@ -159,11 +157,11 @@ class TimeExtCalculationsTest < Test::Unit::TestCase time = Time.utc(2005, 2, 21, 17, 44, 30) assert_equal "Mon, 21 Feb 2005 17:44:30 +0000", time.to_s(:rfc822) end - + def test_to_date assert_equal Date.new(2005, 2, 21), Time.local(2005, 2, 21, 17, 44, 30).to_date end - + def test_to_time assert_equal Time.local(2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30).to_time end @@ -202,7 +200,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase def test_last_month_on_31st assert_equal Time.local(2004, 2, 29), Time.local(2004, 3, 31).last_month end - + def test_xmlschema_is_available assert_nothing_raised { Time.now.xmlschema } end -- cgit v1.2.3