modules test
|
1 |
use Test::More 'no_plan'; |
added a test case for furthe...
|
2 | |
modules test
|
3 |
use FindBin; |
4 |
use lib "$FindBin::Bin/../lib"; |
|
5 |
use lib "$FindBin::Bin/../extlib/lib/perl5"; |
|
added a test case for furthe...
|
6 | |
7 |
use Gitprep::Git; |
|
8 | ||
9 |
my @cases = ( |
|
fixed a typo
|
10 |
{ stimulus => 0, expected => 'right now' }, |
more tests
|
11 |
{ stimulus => 1, expected => 'a sec ago' }, |
12 |
{ stimulus => 59, expected => '59 sec ago' }, |
|
13 |
{ stimulus => 60, expected => 'a min ago' }, |
|
14 |
{ stimulus => 60 + 1, expected => 'a min ago' }, |
|
15 |
{ stimulus => 2 * 60 - 1, expected => 'a min ago' }, |
|
16 |
{ stimulus => 2 * 60, expected => '2 min ago' }, |
|
17 |
{ stimulus => 2 * 60 + 1, expected => '2 min ago' }, |
|
18 |
{ stimulus => 60 * 60 - 1, expected => '59 min ago' }, |
|
more phonetically correct
|
19 |
{ stimulus => 60 * 60, expected => 'an hour ago' }, |
20 |
{ stimulus => 60 * 60 + 1, expected => 'an hour ago' }, |
|
21 |
{ stimulus => 61 * 60, expected => 'an hour ago' }, |
|
more tests
|
22 |
{ stimulus => 24 * 60 * 60 - 1, expected => '23 hours ago' }, |
23 |
{ stimulus => 24 * 60 * 60, expected => 'a day ago' }, |
|
24 |
{ stimulus => 24 * 60 * 60 + 1, expected => 'a day ago' }, |
|
25 |
{ stimulus => 7 * 24 * 60 * 60 - 1, expected => '6 days ago' }, |
|
26 |
{ stimulus => 7 * 24 * 60 * 60, expected => 'a week ago' }, |
|
27 |
{ stimulus => 7 * 24 * 60 * 60 + 1, expected => 'a week ago' }, |
|
28 |
{ stimulus => (365/12) * 24 * 60 * 60 - 1, expected => '4 weeks ago' }, |
|
29 |
{ stimulus => (365/12) * 24 * 60 * 60, expected => 'a month ago' }, |
|
30 |
{ stimulus => (365/12) * 24 * 60 * 60 + 1, expected => 'a month ago' }, |
|
31 |
{ stimulus => 365 * 24 * 60 * 60 - 1, expected => '11 months ago' }, |
|
32 |
{ stimulus => 365 * 24 * 60 * 60, expected => 'a year ago' }, |
|
33 |
{ stimulus => 365 * 24 * 60 * 60 + 1, expected => 'a year ago' }, |
|
34 |
{ stimulus => 2 * 365 * 24 * 60 * 60 - 1, expected => 'a year ago' }, |
|
35 |
{ stimulus => 2 * 365 * 24 * 60 * 60, expected => '2 years ago' }, |
|
36 |
{ stimulus => 2 * 365 * 24 * 60 * 60 + 1, expected => '2 years ago' }, |
|
added a test case for furthe...
|
37 |
); |
38 | ||
39 |
for ( @cases ) { |
|
modules test
|
40 |
is ( Gitprep::Git->new->_age_string ( $_->{stimulus} ), $_->{expected}, "$_->{stimulus} sec ~ \"$_->{expected}\"" ); |
added a test case for furthe...
|
41 |
} |