diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-31 12:34:31 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-31 12:34:31 +0000 |
commit | fbc42054e8375a532b2e0a3b82dded952c8992f7 (patch) | |
tree | 2b59543c81d4d94ffb7d950629ad8ebe0fae30b1 /test/ruby/test_time.rb | |
parent | 59ad28c261af83d17d65025df8aaea9214833f6d (diff) |
* time.c: less bignum allocations.
* strftime.c (rb_strftime_timespec): defined to avoid rational for
nano second resolution time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_time.rb')
-rw-r--r-- | test/ruby/test_time.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 5543951778..108fcdbc20 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -172,6 +172,15 @@ class TestTime < Test::Unit::TestCase t = Time.at(2**40 + "1/3".to_r, 9999999999999).utc assert_equal(36812, t.year) + + t = Time.at(-0x3fff_ffff_ffff_ffff) + assert_equal(-146138510344, t.year) + t = Time.at(-0x4000_0000_0000_0000) + assert_equal(-146138510344, t.year) + t = Time.at(-0x4000_0000_0000_0001) + assert_equal(-146138510344, t.year) + t = Time.at(-0x5000_0000_0000_0001) + assert_equal(-182673138422, t.year) end def test_at2 @@ -579,6 +588,26 @@ class TestTime < Test::Unit::TestCase assert_equal("JANUARY", T2000.strftime("%#B")) assert_equal("JAN", T2000.strftime("%#h")) assert_equal("FRIDAY", Time.local(2008,1,4).strftime("%#A")) + + t = Time.utc(2000,3,14, 6,53,"58.979323846".to_r) # Pi Day + assert_equal("03/14/2000 6:53:58.97932384600000000000000000000", + t.strftime("%m/%d/%Y %l:%M:%S.%29N")) + assert_equal("03/14/2000 6:53:58.9793238460", + t.strftime("%m/%d/%Y %l:%M:%S.%10N")) + assert_equal("03/14/2000 6:53:58.979323846", + t.strftime("%m/%d/%Y %l:%M:%S.%9N")) + assert_equal("03/14/2000 6:53:58.97932384", + t.strftime("%m/%d/%Y %l:%M:%S.%8N")) + + t = Time.utc(1592,3,14, 6,53,"58.97932384626433832795028841971".to_r) # Pi Day + assert_equal("03/14/1592 6:53:58.97932384626433832795028841971", + t.strftime("%m/%d/%Y %l:%M:%S.%29N")) + assert_equal("03/14/1592 6:53:58.9793238462", + t.strftime("%m/%d/%Y %l:%M:%S.%10N")) + assert_equal("03/14/1592 6:53:58.979323846", + t.strftime("%m/%d/%Y %l:%M:%S.%9N")) + assert_equal("03/14/1592 6:53:58.97932384", + t.strftime("%m/%d/%Y %l:%M:%S.%8N")) end def test_delegate |