Re: Analysis of problems with mixed encoding case insensitive matches in regex engine.
[p5sagit/p5-mst-13.2.git] / t / op / time.t
index 870a8dc..8b2f07d 100755 (executable)
@@ -1,28 +1,14 @@
 #!./perl
 
-# $RCSfile: time.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:32 $
+$does_gmtime = gmtime(time);
 
-if ( $does_gmtime = gmtime(time) ) { 
-    print "1..7\n" 
-}
-else { 
-    print "1..4\n" 
-}
-
-
-my $test = 1;
-sub ok ($$) {
-    my($ok, $name) = @_;
-
-    # You have to do it this way or VMS will get confused.
-    print $ok ? "ok $test - $name\n" : "not ok $test - $name\n";
-
-    printf "# Failed test at line %d\n", (caller)[2] unless $ok;
-
-    $test++;
-    return $ok;
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
 }
 
+plan tests => 8;
 
 ($beguser,$begsys) = times;
 
@@ -32,14 +18,15 @@ while (($now = time) == $beg) { sleep 1 }
 
 ok($now > $beg && $now - $beg < 10,             'very basic time test');
 
-for ($i = 0; $i < 100000; $i++) {
+for ($i = 0; $i < 1_000_000; $i++) {
+    for my $j (1..100) {}; # burn some user cycles
     ($nowuser, $nowsys) = times;
-    $i = 200000 if $nowuser > $beguser && ( $nowsys > $begsys || 
+    $i = 2_000_000 if $nowuser > $beguser && ( $nowsys >= $begsys ||
                                             (!$nowsys && !$begsys));
     last if time - $beg > 20;
 }
 
-ok($i >= 200000,                                'very basic times test');
+ok($i >= 2_000_000, 'very basic times test');
 
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
 ($xsec,$foo) = localtime($now);
@@ -54,7 +41,23 @@ ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
    'localtime(), scalar context'
   );
 
-exit 0 unless $does_gmtime;
+SKIP: {
+    # This conditional of "No tzset()" is stolen from ext/POSIX/t/time.t
+    skip "No tzset()", 1
+        if $^O eq "MacOS" || $^O eq "VMS" || $^O eq "cygwin" ||
+           $^O eq "djgpp" || $^O eq "MSWin32" || $^O eq "dos" ||
+           $^O eq "interix";
+
+# check that localtime respects changes to $ENV{TZ}
+$ENV{TZ} = "GMT-5";
+($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+$ENV{TZ} = "GMT+5";
+($sec,$min,$hour2,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+ok($hour != $hour2,                             'changes to $ENV{TZ} respected');
+}
+
+SKIP: {
+    skip "No gmtime()", 3 unless $does_gmtime;
 
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg);
 ($xsec,$foo) = localtime($now);
@@ -73,3 +76,4 @@ ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ]
                /x,
    'gmtime(), scalar context'
   );
+}