File: 01base.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (44 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use Test::More tests => 15;

BEGIN { use_ok('Time::Piece'); }

my $t = gmtime(315532800); # 00:00:00 1/1/1980

isa_ok($t, 'Time::Piece', 'specific gmtime');

cmp_ok($t->year, '==', 1980, 'correct year');

cmp_ok($t->hour, '==',    0, 'correct hour');

cmp_ok($t->mon,  '==',    1, 'correct mon');

my $g = gmtime;
isa_ok($g, 'Time::Piece', 'current gmtime');

my $l = localtime;
isa_ok($l, 'Time::Piece', 'current localtime');

#without export
$g = Time::Piece::gmtime;
isa_ok($g, 'Time::Piece', 'fully qualified gmtime');

$l = Time::Piece::localtime;
isa_ok($l, 'Time::Piece', 'full qualified localtime');

#via new
$l = Time::Piece->new(315532800);
isa_ok($l, 'Time::Piece', 'custom localtime via new');

#via new again
$l = $l->new();
isa_ok($l, 'Time::Piece', 'custom localtime via new again');

#via clone
my $l_clone = Time::Piece->new($l);
isa_ok($l, 'Time::Piece', 'custom localtime via clone');
cmp_ok("$l_clone", 'eq', "$l", 'Clones match');

#via clone with gmtime
my $g_clone = Time::Piece->new($g);
isa_ok($g, 'Time::Piece', 'custom gmtime via clone');
cmp_ok("$g_clone", 'eq', "$g", 'Clones match');