mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
43b80e0988
commit
f79aeb60e7
2 changed files with 19 additions and 17 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Aug 17 23:25:19 2013 Benoit Daloze <eregontp@gmail.com>
|
||||||
|
|
||||||
|
* test/ruby/test_time.rb: use the in_timezone() helper
|
||||||
|
and define it at the top with other helpers.
|
||||||
|
|
||||||
Sat Aug 17 22:20:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Aug 17 22:20:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* time.c (time_mload): ignore auxiliary data, offset and zone, if
|
* time.c (time_mload): ignore auxiliary data, offset and zone, if
|
||||||
|
|
|
@ -15,6 +15,15 @@ class TestTime < Test::Unit::TestCase
|
||||||
$VERBOSE = @verbose
|
$VERBOSE = @verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def in_timezone(zone)
|
||||||
|
orig_zone = ENV['TZ']
|
||||||
|
|
||||||
|
ENV['TZ'] = zone
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
ENV['TZ'] = orig_zone
|
||||||
|
end
|
||||||
|
|
||||||
def no_leap_seconds?
|
def no_leap_seconds?
|
||||||
# 1972-06-30T23:59:60Z is the first leap second.
|
# 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
|
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
|
end
|
||||||
|
|
||||||
def test_marshal_zone
|
def test_marshal_zone
|
||||||
orig_zone = ENV['TZ']
|
|
||||||
|
|
||||||
t = Time.utc(2013, 2, 24)
|
t = Time.utc(2013, 2, 24)
|
||||||
assert_equal('UTC', t.zone)
|
assert_equal('UTC', t.zone)
|
||||||
assert_equal('UTC', Marshal.load(Marshal.dump(t)).zone)
|
assert_equal('UTC', Marshal.load(Marshal.dump(t)).zone)
|
||||||
|
|
||||||
ENV['TZ'] = 'JST-9'
|
in_timezone('JST-9') do
|
||||||
t = Time.local(2013, 2, 24)
|
t = Time.local(2013, 2, 24)
|
||||||
assert_equal('JST', Time.local(2013, 2, 24).zone)
|
assert_equal('JST', Time.local(2013, 2, 24).zone)
|
||||||
assert_equal('JST', Marshal.load(Marshal.dump(t)).zone)
|
assert_equal('JST', Marshal.load(Marshal.dump(t)).zone)
|
||||||
ensure
|
end
|
||||||
ENV['TZ'] = orig_zone
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_marshal_to_s
|
def test_marshal_to_s
|
||||||
|
@ -312,15 +318,6 @@ class TestTime < Test::Unit::TestCase
|
||||||
"[ruby-dev:44827] [Bug #5586]")
|
"[ruby-dev:44827] [Bug #5586]")
|
||||||
end
|
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]'
|
Bug8795 = '[ruby-core:56648] [Bug #8795]'
|
||||||
|
|
||||||
def test_marshal_broken_offset
|
def test_marshal_broken_offset
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue