summaryrefslogtreecommitdiff
path: root/lib/Time/gmtime.t
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Time/gmtime.t')
-rw-r--r--lib/Time/gmtime.t58
1 files changed, 14 insertions, 44 deletions
diff --git a/lib/Time/gmtime.t b/lib/Time/gmtime.t
index 853ec3b6e3..9c77f81570 100644
--- a/lib/Time/gmtime.t
+++ b/lib/Time/gmtime.t
@@ -3,55 +3,25 @@
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 }
+ require "./test.pl";
}
+my(@times, @methods);
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";
+ @times = (-2**62, -2**50, -2**33, -2**31-1, -1, 0, 1, 2**31-1, 2**33, 2**50, 2**62, time);
+ @methods = qw(sec min hour mday mon year wday yday isdst);
+ plan tests => (@times * @methods) + 1;
+ use_ok Time::gmtime;
+}
+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 (@methods) {
+ is $gmtime->$method, shift @gmtime, "gmtime($time)->$method";
+ }
+}