X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F34exception_action.t;h=aa803eb238bada7b3e1e2693e38f39c096bc427a;hb=ea3ee77d2d9e137b07ca4b2db14986e8310f4bec;hp=d7885d5e23e77e1c1ceb10768e2e72f7079428e4;hpb=ddcc02d14d03169c54c65db9f0f446836483ba55;p=dbsrgits%2FDBIx-Class.git diff --git a/t/34exception_action.t b/t/34exception_action.t index d7885d5..aa803eb 100644 --- a/t/34exception_action.t +++ b/t/34exception_action.t @@ -1,10 +1,13 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; use Test::Warn; -use lib qw(t/lib); +use Scalar::Util 'weaken'; + use DBICTest; # Set up the "usual" sqlite for DBICTest @@ -100,14 +103,14 @@ for my $ap (qw( # make sure an exception_action can replace $@ with an antipattern $schema->exception_action(sub { die $ap->new }); - warnings_like { + warnings_exist { eval { $throw->() }; isa_ok $@, $ap; } $exp_warn, 'proper warning on antipattern encountered within exception_action'; # and make sure that the rethrow works $schema->exception_action(sub { die @_ }); - warnings_like { + warnings_exist { eval { $schema->txn_do (sub { die $ap->new }); }; @@ -116,4 +119,19 @@ for my $ap (qw( } $exp_warn, 'Proper warning on encountered antipattern'; } +# ensure we do not get into an infloop +{ + weaken( my $s = $schema ); + + $schema->exception_action(sub{ + $s->throw_exception(@_) + }); + + throws_ok { + $schema->storage->dbh_do(sub { + $_[1]->do('wgwfwfwghawhjsejsethjwetjesjesjsejsetjes') + } ) + } qr/syntax error/i; +} + done_testing;