Blame t/sample.t

Packit e99357
use strict;
Packit e99357
use Test::More;
Packit e99357
use File::Spec ();
Packit e99357
use DateTime::Format::Mail;
Packit e99357
Packit e99357
my $sample = File::Spec->catfile(qw( t sample_dates ));
Packit e99357
my $fh;
Packit e99357
Packit e99357
# Smart open since 5.008 will need to do a raw read rather
Packit e99357
# than interpret the data as anything other than bytes.
Packit e99357
if ( $] >= 5.008 ) {
Packit e99357
    eval 'open $fh, "<:raw", $sample'
Packit e99357
        or die "Cannot open $sample: $!";
Packit e99357
}
Packit e99357
else {
Packit e99357
    open $fh, "< $sample"
Packit e99357
        or die "Cannot open $sample: $!";
Packit e99357
}
Packit e99357
Packit e99357
# Can we parse?
Packit e99357
my $class = 'DateTime::Format::Mail';
Packit e99357
my $f     = $class->new()->loose();
Packit e99357
Packit e99357
while (<$fh>) {
Packit e99357
    chomp;
Packit e99357
    my $p = eval { $f->parse_datetime($_) };
Packit e99357
    ok( ( defined $p and ref $p and not $@), $_ );
Packit e99357
}
Packit e99357
Packit e99357
done_testing;