summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-31 10:40:22 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-31 10:40:22 +0000
commit5c9d45e6e75c02884d13dc197ab9e7c94c98bc11 (patch)
treec328797b6ce8bb8bdc2d59c4de19b0e097443428 /test/ruby
parent9bf44e389ece8f91f517532a61a588f7fdedc8b1 (diff)
add a test. [ruby-dev:22619]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_time.rb18
1 files changed, 14 insertions, 4 deletions
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