mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add a test. [ruby-dev:22619]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9bf44e389e
commit
5c9d45e6e7
1 changed files with 14 additions and 4 deletions
|
@ -24,14 +24,17 @@ class TestTime < Test::Unit::TestCase
|
|||
-Time.utc(2000, 3, 21, 3, 30), -3*3600)
|
||||
end
|
||||
|
||||
def test_timegm
|
||||
def negative_time_t?
|
||||
begin
|
||||
Time.at(-1)
|
||||
negative_time_t_supported = true
|
||||
true
|
||||
rescue ArgumentError
|
||||
negative_time_t_supported = false
|
||||
false
|
||||
end
|
||||
if negative_time_t_supported
|
||||
end
|
||||
|
||||
def test_timegm
|
||||
if negative_time_t?
|
||||
assert_equal(-0x80000000, Time.utc(1901, 12, 13, 20, 45, 52).tv_sec)
|
||||
assert_equal(-2, Time.utc(1969, 12, 31, 23, 59, 58).tv_sec)
|
||||
assert_equal(-1, Time.utc(1969, 12, 31, 23, 59, 59).tv_sec)
|
||||
|
@ -58,4 +61,11 @@ class TestTime < Test::Unit::TestCase
|
|||
assert_equal(946684822, Time.utc(2000, 1, 1, 0, 0, 0).tv_sec)
|
||||
end
|
||||
end
|
||||
|
||||
def test_huge_difference # [ruby-dev:22619]
|
||||
if negative_time_t?
|
||||
assert_equal(Time.at(-0x80000000), Time.at(0x7fffffff) - 0xffffffff)
|
||||
assert_equal(Time.at(0x7fffffff), Time.at(-0x80000000) + 0xffffffff)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue