Skip to content

Commit

Permalink
added a few more Mojo::Date tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 5, 2011
1 parent 422e851 commit fcf95c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/Mojo/Date.pm
Expand Up @@ -13,10 +13,7 @@ has 'epoch';
my @DAYS = qw/Sun Mon Tue Wed Thu Fri Sat/;
my @MONTHS = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
my %MONTHS;
{
my $i = 0;
$MONTHS{$_} = $i++ for @MONTHS;
}
@MONTHS{@MONTHS} = (0 .. 11);

sub new { shift->SUPER::new->parse(@_) }

Expand Down
9 changes: 8 additions & 1 deletion t/mojo/date.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use Mojo::Base -strict;

use Test::More tests => 17;
use Test::More tests => 21;

# "Can't we have one meeting that doesn't end with digging up a corpse?"
use_ok 'Mojo::Date';
Expand All @@ -25,10 +25,17 @@ is Mojo::Date->new('Fri May 13 10:00:24 2011')->epoch,
1305280824, 'right epoch value';

# Invalid string
is Mojo::Date->new('')->epoch, undef, 'no epoch value';
is Mojo::Date->new('123 abc')->epoch, undef, 'no epoch value';
is Mojo::Date->new('abc')->epoch, undef, 'no epoch value';
is Mojo::Date->new('Xxx, 00 Xxx 0000 00:00:00 XXX')->epoch, undef,
'no epoch value';
is Mojo::Date->new('Sun, 06 Nov 1994 08:49:37 GMT GARBAGE')->epoch, undef,
'no epoch value';
is Mojo::Date->new('Sunday, 06-Nov-94 08:49:37 GMT GARBAGE')->epoch, undef,
'no epoch value';
is Mojo::Date->new('Sun Nov 6 08:49:37 1994 GARBAGE')->epoch, undef,
'no epoch value';

# to_string
$date = Mojo::Date->new(784111777);
Expand Down

0 comments on commit fcf95c8

Please sign in to comment.