/Compress/ modules are at version 2.021. Remove vestigal MAPs and comments.
[p5sagit/p5-mst-13.2.git] / ext / POSIX / t / time.t
index 8b30415..103a161 100644 (file)
@@ -4,25 +4,28 @@ use strict;
 
 use Config;
 use POSIX;
-use Test::More qw(no_plan);
+use Test::More tests => 9;
 
-# go to UTC to avoid DST issues around the world when testing
-{
-    no warnings 'uninitialized';
-    $ENV{TZ} = undef;
-}
+# go to UTC to avoid DST issues around the world when testing.  SUS3 says that
+# null should get you UTC, but some environments want the explicit names.
+# Those with a working tzset() should be able to use the TZ below.
+$ENV{TZ} = "UTC0UTC";
 
 SKIP: {
     # It looks like POSIX.xs claims that only VMS and Mac OS traditional
-    # don't have tzset().  A config setting might be helpful.  Win32 actually
-    # seems ambiguous
+    # don't have tzset().  Win32 works to call the function, but it doesn't
+    # actually do anything.  Cygwin works in some places, but not others.  The
+    # other Win32's below are guesses.
     skip "No tzset()", 2
-       if $^O eq "MacOS" || $^O eq "VMS" || $^O eq "cygwin" ||
+       if $^O eq "MacOS" || $^O eq "VMS" || $^O eq "cygwin" || $^O eq "djgpp" ||
           $^O eq "MSWin32" || $^O eq "dos" || $^O eq "interix";
     tzset();
     my @tzname = tzname();
-    like($tzname[0], qr/[GMT|UTC]/i, "tzset() to GMT/UTC");
-    like($tzname[1], qr/[GMT|UTC]/i, "The whole year?");
+    like($tzname[0], qr/(GMT|UTC)/i, "tzset() to GMT/UTC");
+    SKIP: {
+        skip "Mac OS X/Darwin doesn't handle this", 1 if $^O =~ /darwin/i;
+        like($tzname[1], qr/(GMT|UTC)/i, "The whole year?");
+    }
 }
 
 # asctime and ctime...Let's stay below INT_MAX for 32-bits and
@@ -32,17 +35,17 @@ is(asctime(localtime(0)), ctime(0), "asctime() and ctime() at zero");
 is(asctime(localtime(12345678)), ctime(12345678), "asctime() and ctime() at 12345678");
 
 # Careful!  strftime() is locale sensative.  Let's take care of that
-SKIP: {
-    skip "Win32's is missing a %e" if $^O eq "MSWin32";
-    my $orig_loc = setlocale(LC_TIME, "C") || die "Cannot setlocale() to C:  $!";
-    is(ctime(86400), strftime("%a %b %e %H:%M:%S %Y\n", localtime(86400)),
+my $orig_loc = setlocale(LC_TIME, "C") || die "Cannot setlocale() to C:  $!";
+my $jan_16 = 15 * 86400;
+is(ctime($jan_16), strftime("%a %b %d %H:%M:%S %Y\n", localtime($jan_16)),
         "get ctime() equal to strftime()");
-    setlocale(LC_TIME, $orig_loc) || die "Cannot setlocale() back to orig: $!";
-}
+setlocale(LC_TIME, $orig_loc) || die "Cannot setlocale() back to orig: $!";
 
-# Hard to test other than to make sure it returns something numeric and < 0
+# clock() seems to have different definitions of what it does between POSIX
+# and BSD.  Cygwin, Win32, and Linux lean the BSD way.  So, the tests just
+# check the basics.
 like(clock(), qr/\d*/, "clock() returns a numeric value");
-ok(clock() > 0, "...and its greater than zero");
+ok(clock() >= 0, "...and it returns something >= 0");
 
 SKIP: {
     skip "No difftime()", 1 if $Config{d_difftime} ne 'define';