From: Michael G. Schwern Date: Tue, 23 Sep 2008 17:50:16 +0000 (-0700) Subject: Fix the test plan on gmtime X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b9020a0ae3b98b01aa1548eafc93f1236bf49165;p=p5sagit%2Fp5-mst-13.2.git Fix the test plan on gmtime Use the new LOCALTIME_MIN/MAX constants. Use the system gmtime, it'll probably be faster... maybe. --- diff --git a/lib/Time/gmtime.t b/lib/Time/gmtime.t index 383eeda..1ccd7fb 100644 --- a/lib/Time/gmtime.t +++ b/lib/Time/gmtime.t @@ -7,16 +7,22 @@ BEGIN { require "./test.pl"; } -BEGIN { plan tests => 37; } +my(@times, @methods); +BEGIN { + @times = (-2**33, -2**31-1, 0, 2**31-1, 2**33, time); + @methods = qw(sec min hour mday mon year wday yday isdst); + + plan tests => (@times * @methods) + 1; -BEGIN { use_ok Time::gmtime; } + use_ok Time::gmtime; +} # Perl has its own gmtime() so it's safe to do negative times. -for my $time (-2**33, -2**31-1, 0, 2**31-1, 2**33, time) { +for my $time (@times) { my $gmtime = gmtime $time; # This is the OO gmtime. my @gmtime = CORE::gmtime $time; # This is the gmtime function - for my $method (qw(sec min hour mday mon year wday yday isdst)) { + for my $method (@methods) { is $gmtime->$method, shift @gmtime, "gmtime($time)->$method"; } } diff --git a/localtime64.h b/localtime64.h index fed1946..5bae08a 100644 --- a/localtime64.h +++ b/localtime64.h @@ -24,16 +24,14 @@ USE_SYSTEM_GMTIME Should we use the system functions if the time is inside their range? */ -#define SYSTEM_LOCALTIME_MAX 2147483647 /* XXX Replace with LOCALTIME_MAX */ -#define SYSTEM_LOCALTIME_MIN -2147483647 /* XXX Replace with LOCALTIME_MIN */ +#define SYSTEM_LOCALTIME_MAX LOCALTIME_MAX +#define SYSTEM_LOCALTIME_MIN LOCALTIME_MIN #define SYSTEM_GMTIME_MAX GMTIME_MAX #define SYSTEM_GMTIME_MIN GMTIME_MIN -/* It'll be faster */ +/* The system localtime will be faster and more correct inside its range */ #define USE_SYSTEM_LOCALTIME 1 - -/* No point risking system bugs, ours works fine */ -#define USE_SYSTEM_GMTIME 0 +#define USE_SYSTEM_GMTIME 1 /* 64 bit types. Set as appropriate for your system. */