From 5c9d45e6e75c02884d13dc197ab9e7c94c98bc11 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 31 Mar 2004 10:40:22 +0000 Subject: add a test. [ruby-dev:22619] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_time.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 28286ddc04..d3707bf58d 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -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 -- cgit v1.2.3