convert all uses of Test::Exception to Test::Fatal.
[gitmo/Moose.git] / t / 040_type_constraints / 034_duck_types.t
index 87aca90..838c2e8 100644 (file)
@@ -2,8 +2,8 @@
 use strict;
 use warnings;
 
-use Test::More tests => 4;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 
 {
 
@@ -39,6 +39,7 @@ use Test::Exception;
     use Moose::Util::TypeConstraints;
 
     duck_type 'DuckType' => qw(quack);
+    duck_type 'SwanType' => [qw(honk)];
 
     has duck => (
         isa        => 'DuckType',
@@ -53,20 +54,29 @@ use Test::Exception;
         is => 'ro',
     );
 
+    has other_swan => (
+        isa => 'SwanType',
+        is => 'ro',
+    );
+
 }
 
 # try giving it a duck
-lives_ok { DucktypeTest->new( duck => Duck->new ) } 'the Duck lives okay';
+ok ! exception { DucktypeTest->new( duck => Duck->new ) }, 'the Duck lives okay';
 
 # try giving it a swan which is like a duck, but not close enough
-throws_ok { DucktypeTest->new( duck => Swan->new ) }
+like exception { DucktypeTest->new( duck => Swan->new ) },
 qr/Swan is missing methods 'quack'/,
     "the Swan doesn't quack";
 
 # try giving it a rubber RubberDuckey
-lives_ok { DucktypeTest->new( swan => Swan->new ) } 'but a Swan can honk';
+ok ! exception { DucktypeTest->new( swan => Swan->new ) }, 'but a Swan can honk';
 
 # try giving it a rubber RubberDuckey
-lives_ok { DucktypeTest->new( duck => RubberDuck->new ) }
+ok ! exception { DucktypeTest->new( duck => RubberDuck->new ) },
 'the RubberDuck lives okay';
 
+# try with the other constraint form
+ok ! exception { DucktypeTest->new( other_swan => Swan->new ) }, 'but a Swan can honk';
+
+done_testing;