Redid conversion to Test::Fatal
[gitmo/Moose.git] / t / 040_type_constraints / 007_util_more_type_coercion.t
index c24d6bc..7c5f30a 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use Test::More;
-use Test::Exception;
+use Test::Fatal;
 
 
 {
@@ -37,9 +37,9 @@ use Test::Exception;
 
     # try with arrays
 
-    lives_ok {
+    is( exception {
         $engine->header([ 1, 2, 3 ]);
-    } '... type was coerced without incident';
+    }, undef, '... type was coerced without incident' );
     isa_ok($engine->header, 'HTTPHeader');
 
     is_deeply(
@@ -50,9 +50,9 @@ use Test::Exception;
 
     # try with hash
 
-    lives_ok {
+    is( exception {
         $engine->header({ one => 1, two => 2, three => 3 });
-    } '... type was coerced without incident';
+    }, undef, '... type was coerced without incident' );
     isa_ok($engine->header, 'HTTPHeader');
 
     is_deeply(
@@ -61,13 +61,13 @@ use Test::Exception;
         '... got the right hash value of the header');
     ok(!defined($engine->header->array), '... no array value set');
 
-    dies_ok {
+    isnt( exception {
        $engine->header("Foo");
-    } '... dies with the wrong type, even after coercion';
+    }, undef, '... dies with the wrong type, even after coercion' );
 
-    lives_ok {
+    is( exception {
        $engine->header(HTTPHeader->new);
-    } '... lives with the right type, even after coercion';
+    }, undef, '... lives with the right type, even after coercion' );
 }
 
 {
@@ -106,13 +106,13 @@ use Test::Exception;
     ok(!defined($engine->header->array), '... no array value set');
 }
 
-dies_ok {
+isnt( exception {
     Engine->new(header => 'Foo');
-} '... dies correctly with bad params';
+}, undef, '... dies correctly with bad params' );
 
-dies_ok {
+isnt( exception {
     Engine->new(header => \(my $var));
-} '... dies correctly with bad params';
+}, undef, '... dies correctly with bad params' );
 
 {
     my $tc = Moose::Util::TypeConstraints::find_type_constraint('HTTPHeader');
@@ -126,9 +126,7 @@ dies_ok {
     isa_ok($from_href, 'HTTPHeader', 'assert_coerce from href to HTTPHeader');
     is_deeply($from_href->hash, { a => 1 }, '...and has the right guts');
 
-    throws_ok { $tc->assert_coerce('total garbage') }
-      qr/Validation failed for .HTTPHeader./,
-      "assert_coerce throws if result is not acceptable";
+    like( exception { $tc->assert_coerce('total garbage') }, qr/Validation failed for .HTTPHeader./, "assert_coerce throws if result is not acceptable" );
 }
 
 done_testing;