summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2008-10-04 18:24:54 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-01-03 18:39:16 +0100
commit461d5a49bcaf1bdc023edb10ef9b6c0606ec0131 (patch)
treeb320c5fc7d5618b148e9437543445ba6ec23e764 /t
parentb86b480f7301a8816081189c89b366a79ab9909f (diff)
downloadperl-461d5a49bcaf1bdc023edb10ef9b6c0606ec0131.tar.gz
Update from y2038.
Add trace code. Fix implied negative time in localtie64_r(). This fixes Windows. Put in some more tests around small negative and positive times to try and catch the above. Explain the loss of accuracy due to use of doubles in perlport.
Diffstat (limited to 't')
-rwxr-xr-xt/op/time.t29
1 files changed, 17 insertions, 12 deletions
diff --git a/t/op/time.t b/t/op/time.t
index 2e61eea77f..00c5b0501c 100755
--- a/t/op/time.t
+++ b/t/op/time.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 34;
+plan tests => 42;
($beguser,$begsys) = times;
@@ -82,16 +82,19 @@ ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
# Test gmtime over a range of times.
{
# gm/localtime should go all the way from -2**63 to 2**63-1
+ # but floating point hacks mean it gets unreliable for large numbers.
my %tests = (
# time_t gmtime list scalar
- -2**35 => [52, 13, 20, 7, 2, -1019, 5, 65, 0, "Fri Mar 7 20:13:52 881"],
- -2**32 => [44, 31, 17, 24, 10, -67, 0, 327, 0, "Sun Nov 24 17:31:44 1833"],
- -2**31 => [52, 45, 20, 13, 11, 1, 5, 346, 0, "Fri Dec 13 20:45:52 1901"],
- 0 => [0, 0, 0, 1, 0, 70, 4, 0, 0, "Thu Jan 1 00:00:00 1970"],
- 2**30 => [4, 37, 13, 10, 0, 104, 6, 9, 0, "Sat Jan 10 13:37:04 2004"],
- 2**31 => [8, 14, 3, 19, 0, 138, 2, 18, 0, "Tue Jan 19 03:14:08 2038"],
- 2**32 => [16, 28, 6, 7, 1, 206, 0, 37, 0, "Sun Feb 7 06:28:16 2106"],
- 2**39 => [8, 18, 12, 25, 0, 17491, 2, 24, 0, "Tue Jan 25 12:18:08 19391"],
+ -2**35 => [52, 13, 20, 7, 2, -1019, 5, 65, 0, "Fri Mar 7 20:13:52 881"],
+ -2**32 => [44, 31, 17, 24, 10, -67, 0, 327, 0, "Sun Nov 24 17:31:44 1833"],
+ -2**31 => [52, 45, 20, 13, 11, 1, 5, 346, 0, "Fri Dec 13 20:45:52 1901"],
+ -1 => [59, 59, 23, 31, 11, 69, 3, 364, 0, "Wed Dec 31 23:59:59 1969"],
+ 0 => [0, 0, 0, 1, 0, 70, 4, 0, 0, "Thu Jan 1 00:00:00 1970"],
+ 1 => [1, 0, 0, 1, 0, 70, 4, 0, 0, "Thu Jan 1 00:00:01 1970"],
+ 2**30 => [4, 37, 13, 10, 0, 104, 6, 9, 0, "Sat Jan 10 13:37:04 2004"],
+ 2**31 => [8, 14, 3, 19, 0, 138, 2, 18, 0, "Tue Jan 19 03:14:08 2038"],
+ 2**32 => [16, 28, 6, 7, 1, 206, 0, 37, 0, "Sun Feb 7 06:28:16 2106"],
+ 2**39 => [8, 18, 12, 25, 0, 17491, 2, 24, 0, "Tue Jan 25 12:18:08 19391"],
);
for my $time (keys %tests) {
@@ -110,9 +113,11 @@ ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
# the same regardless of the time zone.
my %tests = (
# time_t month, year, scalar
- -8589934592 => [9, -203, qr/Oct \d+ .* 1697$/],
- 5000000000 => [5, 228, qr/Jun \d+ .* 2128$/],
- 1163500000 => [10, 106, qr/Nov \d+ .* 2006$/],
+ -8589934592 => [9, -203, qr/Oct \d+ .* 1697$/],
+ -1296000 => [11, 69, qr/Dec \d+ .* 1969$/],
+ 1296000 => [0, 70, qr/Jan \d+ .* 1970$/],
+ 5000000000 => [5, 228, qr/Jun \d+ .* 2128$/],
+ 1163500000 => [10, 106, qr/Nov \d+ .* 2006$/],
);
for my $time (keys %tests) {