summaryrefslogtreecommitdiff
path: root/test/ruby/test_time.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-17 14:25:34 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-17 14:25:34 +0000
commitf79aeb60e7e49c0430f2685719c8c4772cfc6f95 (patch)
treecfd3189e6607832a5ddfe0f0b70b461dd8d124ca /test/ruby/test_time.rb
parent43b80e0988251f1d53de06d8f294f48ba9eb0a25 (diff)
* test/ruby/test_time.rb: use the in_timezone() helper
and define it at the top with other helpers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_time.rb')
-rw-r--r--test/ruby/test_time.rb31
1 files changed, 14 insertions, 17 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index ba3b2ee314..ec6986a824 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -15,6 +15,15 @@ class TestTime < Test::Unit::TestCase
$VERBOSE = @verbose
end
+ def in_timezone(zone)
+ orig_zone = ENV['TZ']
+
+ ENV['TZ'] = zone
+ yield
+ ensure
+ ENV['TZ'] = orig_zone
+ end
+
def no_leap_seconds?
# 1972-06-30T23:59:60Z is the first leap second.
Time.utc(1972, 7, 1, 0, 0, 0) - Time.utc(1972, 6, 30, 23, 59, 59) == 1
@@ -291,18 +300,15 @@ class TestTime < Test::Unit::TestCase
end
def test_marshal_zone
- orig_zone = ENV['TZ']
-
t = Time.utc(2013, 2, 24)
assert_equal('UTC', t.zone)
assert_equal('UTC', Marshal.load(Marshal.dump(t)).zone)
- ENV['TZ'] = 'JST-9'
- t = Time.local(2013, 2, 24)
- assert_equal('JST', Time.local(2013, 2, 24).zone)
- assert_equal('JST', Marshal.load(Marshal.dump(t)).zone)
- ensure
- ENV['TZ'] = orig_zone
+ in_timezone('JST-9') do
+ t = Time.local(2013, 2, 24)
+ assert_equal('JST', Time.local(2013, 2, 24).zone)
+ assert_equal('JST', Marshal.load(Marshal.dump(t)).zone)
+ end
end
def test_marshal_to_s
@@ -312,15 +318,6 @@ class TestTime < Test::Unit::TestCase
"[ruby-dev:44827] [Bug #5586]")
end
- def in_timezone(zone)
- orig_zone = ENV['TZ']
-
- ENV['TZ'] = zone
- yield
- ensure
- ENV['TZ'] = orig_zone
- end
-
Bug8795 = '[ruby-core:56648] [Bug #8795]'
def test_marshal_broken_offset