1#!perl -Tw 2 3use warnings; 4use strict; 5 6use Test::More; 7 8use Carp::Assert::More; 9 10my $module = 'DateTime'; 11 12if ( !eval "use $module; 1;" ) { ## no critic (ProhibitStringyEval) 13 plan skip_all => "$module required for testing assert_datetime()"; 14} 15 16plan tests => 11; 17 18my %bad = ( 19 'hashref' => {}, 20 'undef' => undef, 21 'integer' => 17, 22 'coderef' => \&like, 23 'date string' => '1941-12-07', 24); 25 26while ( my ($desc,$val) = each %bad ) { 27 my $rc = eval { assert_datetime( $val ); 1 }; 28 29 is( $rc, undef, "assertion did not pass: $desc" ); 30 like( $@, qr/Assertion.+failed/, "Error message matches: $desc" ); 31} 32 33 34my $dt = DateTime->now; 35assert_datetime( $dt ); 36pass( 'Got past a valid assertion' ); 37 38exit 0; 39