Implement and export dies_ok
[gitmo/Mouse.git] / lib / Mouse / Util.pm
index 7d0c97d..341efe7 100644 (file)
@@ -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) {
@@ -204,8 +214,8 @@ BEGIN {
 
         $loaded{$module_name} = $loaded;
 
-        for my $method_name (keys %{ $dependencies{ $module_name } }) {
-            my $producer = $dependencies{$module_name}{$method_name};
+        for my $method_name (keys %{ $dependencies{ $module } }) {
+            my $producer = $dependencies{$module}{$method_name};
             my $implementation;
 
             if (ref($producer) eq 'HASH') {
@@ -258,6 +268,8 @@ without L<Scalar::Util>, an error is thrown.
 
 =head3 throws_ok
 
+=head3 dies_ok
+
 =head3 lives_ok
 
 =cut