From: Jarkko Hietaniemi Date: Tue, 29 May 2001 15:29:37 +0000 (+0000) Subject: Add tests for Time::gmtime and Time::localtime. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2857d2f75f0c461bb6df408dedb4450b2e1c89de;p=p5sagit%2Fp5-mst-13.2.git Add tests for Time::gmtime and Time::localtime. p4raw-id: //depot/perl@10291 --- diff --git a/MANIFEST b/MANIFEST index c2c6970..8c5d582 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1656,7 +1656,9 @@ t/lib/tie-stdarray.t Test for Tie::StdArray t/lib/tie-stdhandle.t Test for Tie::StdHandle t/lib/tie-stdpush.t Test for Tie::StdArray t/lib/tie-substrhash.t Test for Tie::SubstrHash +t/lib/time-gmtime.t Test for Time::gmtime t/lib/time-hires.t Test for Time::HiRes +t/lib/time-localtime.t Test for Time::localtime t/lib/time-piece.t Test for Time::Piece t/lib/timelocal.t See if Time::Local works t/lib/trig.t See if Math::Trig works diff --git a/t/lib/1_compile.t b/t/lib/1_compile.t index 2670e7a..eb2d70b 100644 --- a/t/lib/1_compile.t +++ b/t/lib/1_compile.t @@ -237,6 +237,9 @@ Tie::SubstrHash Time::HiRes Time::Local Time::Piece +Time::gmtime +Time::localtime +Time::tm UNIVERSAL User::grent User::pwent diff --git a/t/lib/time-gmtime.t b/t/lib/time-gmtime.t new file mode 100644 index 0000000..853ec3b --- /dev/null +++ b/t/lib/time-gmtime.t @@ -0,0 +1,57 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +BEGIN { + our $hasgm; + eval { my $n = gmtime 0 }; + $hasgm = 1 unless $@ && $@ =~ /unimplemented/; + unless ($hasgm) { print "1..0 # Skip: no gmtime\n"; exit 0 } +} + +BEGIN { + our @gmtime = gmtime 0; # This is the function gmtime. + unless (@gmtime) { print "1..0 # Skip: gmtime failed\n"; exit 0 } +} + +print "1..10\n"; + +use Time::gmtime; + +print "ok 1\n"; + +my $gmtime = gmtime 0 ; # This is the OO gmtime. + +print "not " unless $gmtime->sec == $gmtime[0]; +print "ok 2\n"; + +print "not " unless $gmtime->min == $gmtime[1]; +print "ok 3\n"; + +print "not " unless $gmtime->hour == $gmtime[2]; +print "ok 4\n"; + +print "not " unless $gmtime->mday == $gmtime[3]; +print "ok 5\n"; + +print "not " unless $gmtime->mon == $gmtime[4]; +print "ok 6\n"; + +print "not " unless $gmtime->year == $gmtime[5]; +print "ok 7\n"; + +print "not " unless $gmtime->wday == $gmtime[6]; +print "ok 8\n"; + +print "not " unless $gmtime->yday == $gmtime[7]; +print "ok 9\n"; + +print "not " unless $gmtime->isdst == $gmtime[8]; +print "ok 10\n"; + + + + diff --git a/t/lib/time-localtime.t b/t/lib/time-localtime.t new file mode 100644 index 0000000..357615c --- /dev/null +++ b/t/lib/time-localtime.t @@ -0,0 +1,57 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +BEGIN { + our $haslocal; + eval { my $n = localtime 0 }; + $haslocal = 1 unless $@ && $@ =~ /unimplemented/; + unless ($haslocal) { print "1..0 # Skip: no localtime\n"; exit 0 } +} + +BEGIN { + our @localtime = localtime 0; # This is the function localtime. + unless (@localtime) { print "1..0 # Skip: localtime failed\n"; exit 0 } +} + +print "1..10\n"; + +use Time::localtime; + +print "ok 1\n"; + +my $localtime = localtime 0 ; # This is the OO localtime. + +print "not " unless $localtime->sec == $localtime[0]; +print "ok 2\n"; + +print "not " unless $localtime->min == $localtime[1]; +print "ok 3\n"; + +print "not " unless $localtime->hour == $localtime[2]; +print "ok 4\n"; + +print "not " unless $localtime->mday == $localtime[3]; +print "ok 5\n"; + +print "not " unless $localtime->mon == $localtime[4]; +print "ok 6\n"; + +print "not " unless $localtime->year == $localtime[5]; +print "ok 7\n"; + +print "not " unless $localtime->wday == $localtime[6]; +print "ok 8\n"; + +print "not " unless $localtime->yday == $localtime[7]; +print "ok 9\n"; + +print "not " unless $localtime->isdst == $localtime[8]; +print "ok 10\n"; + + + +