Data-Handle
view release on metacpan or search on metacpan
t/04_things_that_fail.t view on Meta::CPAN
use strict;
use warnings;
use Test::More tests => 146;
use Test::Fatal;
use Data::Handle;
my $id = 0;
our $numfails = 0;
sub checkisa {
my ( $exception, @types ) = @_;
my (@caller) = caller();
my $needdiag = 0;
local $numfails = 0;
$id++;
note "(fake) subtest: checkisa $id ---- ";
note explain \@types;
CHECKISA_FC: {
if ( not defined $exception ) {
my $fail = fail( sprintf 'checkisa(\$exception, %s ) didn\'t receive anything useful', explain(@types) );
diag( explain( { exception => $exception } ) );
$numfails++;
last CHECKISA_FC;
}
else {
pass("Exception is defined");
}
if ( not ref $exception ) {
my $fail = fail( sprintf 'checkisa($exception, %s ) didn\'t receive a ref', explain(@types) );
diag( explain( { exception => $exception } ) );
$numfails++;
last CHECKISA_FC;
}
else {
pass( sprintf q[Exception is a ref ( %s ) ], ref $exception );
}
for my $type (@types) {
( $needdiag++, $numfails++ )
unless isa_ok( $exception, $type, 'Expected Exception Type ' . $type );
}
}
diag($exception) if $needdiag;
note( explain( \@caller ) ) if $needdiag;
note "end (fake) subtest: checkisa $id ---";
return 0 == $numfails;
}
use lib 't/lib';
use Data;
my ( $handle, $e );
isnt(
$e = exception {
Data::Handle->_get_data_symbol('Data_That_Isn\'t_there');
},
undef,
'_get_data_symbol Fails if DATA is not there'
);
checkisa( $e, ( 'Data::Handle::Exception::Internal::BadGet', 'Data::Handle::Exception::Internal', 'Data::Handle::Exception', ) );
( run in 1.048 second using v1.01-cache-2.11-cpan-54e63673c56 )