From: Shawn M Moore Date: Sat, 29 Nov 2008 01:01:07 +0000 (+0000) Subject: Implement and export dies_ok X-Git-Tag: 0.19~148 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=295123ff081b91a1691b4dd5a710a1e371200662;p=gitmo%2FMouse.git Implement and export dies_ok --- diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 04c5ee4..341efe7 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -182,6 +182,16 @@ BEGIN { $@ = $exception; return $ok; }, + 'dies_ok' => sub (&;$) { + my ( $coderef, $description ) = @_; + my $exception = $try_as_caller->( $coderef ); + + $Tester ||= Test::Builder->new; + + my $ok = $Tester->ok( $is_exception->( $exception ), $description ); + $@ = $exception; + return $ok; + }, }, }, ); @@ -191,7 +201,7 @@ BEGIN { our @EXPORT_OK = map { keys %$_ } values %dependencies; our %EXPORT_TAGS = ( all => \@EXPORT_OK, - test => [qw/throws_ok lives_ok/], + test => [qw/throws_ok lives_ok dies_ok/], ); for my $module (keys %dependencies) { @@ -258,6 +268,8 @@ without L, an error is thrown. =head3 throws_ok +=head3 dies_ok + =head3 lives_ok =cut