xref: /openbsd-src/gnu/usr.bin/perl/cpan/Time-Piece/t/03compare.t (revision 5759b3d249badf144a6240f7eec4dcf9df003e6b)
1use Test::More;
2BEGIN { plan tests => 11 }
3use Time::Piece;
4
5my @t = ('2002-01-01 00:00',
6         '2002-01-01 01:20');
7
8@t = map Time::Piece->strptime($_, '%Y-%m-%d %H:%M'), @t;
9
10ok($t[0] < $t[1]);
11ok($t[0] < $t[1]->epoch);
12
13ok($t[0] != $t[1]);
14
15ok($t[0] == $t[0]);
16ok($t[0] == $t[0]->epoch);
17
18ok($t[0] != $t[1]);
19
20ok($t[0] <= $t[1]);
21ok($t[0] <= $t[1]->epoch);
22
23is($t[0] cmp $t[1], -1);
24is($t[1] cmp $t[0],  1);
25is($t[0] cmp $t[0],  0);
26