xref: /openbsd/gnu/usr.bin/perl/cpan/Time-Piece/t/01base.t (revision 09467b48)
1use Test::More tests => 15;
2
3BEGIN { use_ok('Time::Piece'); }
4
5my $t = gmtime(315532800); # 00:00:00 1/1/1980
6
7isa_ok($t, 'Time::Piece', 'specific gmtime');
8
9cmp_ok($t->year, '==', 1980, 'correct year');
10
11cmp_ok($t->hour, '==',    0, 'correct hour');
12
13cmp_ok($t->mon,  '==',    1, 'correct mon');
14
15my $g = gmtime;
16isa_ok($g, 'Time::Piece', 'current gmtime');
17
18my $l = localtime;
19isa_ok($l, 'Time::Piece', 'current localtime');
20
21#without export
22$g = Time::Piece::gmtime;
23isa_ok($g, 'Time::Piece', 'fully qualified gmtime');
24
25$l = Time::Piece::localtime;
26isa_ok($l, 'Time::Piece', 'full qualified localtime');
27
28#via new
29$l = Time::Piece->new(315532800);
30isa_ok($l, 'Time::Piece', 'custom localtime via new');
31
32#via new again
33$l = $l->new();
34isa_ok($l, 'Time::Piece', 'custom localtime via new again');
35
36#via clone
37my $l_clone = Time::Piece->new($l);
38isa_ok($l, 'Time::Piece', 'custom localtime via clone');
39cmp_ok("$l_clone", 'eq', "$l", 'Clones match');
40
41#via clone with gmtime
42my $g_clone = Time::Piece->new($g);
43isa_ok($g, 'Time::Piece', 'custom gmtime via clone');
44cmp_ok("$g_clone", 'eq', "$g", 'Clones match');
45