clean up ::Destructor
[gitmo/Moose.git] / t / 020_attributes / 005_attribute_does.t
index 01145f8..43deb4b 100644 (file)
@@ -3,9 +3,8 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
-use Test::Exception;
-
+use Test::More;
+use Test::Fatal;
 
 
 {
@@ -19,9 +18,14 @@ use Test::Exception;
     has 'bar' => (is => 'rw', does => 'Bar::Role');
     has 'baz' => (
         is   => 'rw',
-        does => subtype('Role', where { $_->does('Bar::Role') })
+        does => role_type('Bar::Role')
     );
 
+    package Foo::Class;
+    use Moose;
+
+    with 'Foo::Role';
+
     package Bar::Role;
     use Moose::Role;
 
@@ -30,16 +34,10 @@ use Test::Exception;
     # since the isa() check will imply the does() check
     has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role');
 
-    package Foo::Class;
-    use Moose;
-
-    with 'Foo::Role';
-
     package Bar::Class;
     use Moose;
 
     with 'Bar::Role';
-
 }
 
 my $foo = Foo::Class->new;
@@ -48,25 +46,25 @@ isa_ok($foo, 'Foo::Class');
 my $bar = Bar::Class->new;
 isa_ok($bar, 'Bar::Class');
 
-lives_ok {
+is( exception {
     $foo->bar($bar);
-} '... bar passed the type constraint okay';
+}, undef, '... bar passed the type constraint okay' );
 
-dies_ok {
+isnt( exception {
     $foo->bar($foo);
-} '... foo did not pass the type constraint okay';
+}, undef, '... foo did not pass the type constraint okay' );
 
-lives_ok {
+is( exception {
     $foo->baz($bar);
-} '... baz passed the type constraint okay';
+}, undef, '... baz passed the type constraint okay' );
 
-dies_ok {
+isnt( exception {
     $foo->baz($foo);
-} '... foo did not pass the type constraint okay';
+}, undef, '... foo did not pass the type constraint okay' );
 
-lives_ok {
+is( exception {
     $bar->foo($foo);
-} '... foo passed the type constraint okay';
+}, undef, '... foo passed the type constraint okay' );
 
 
 
@@ -78,9 +76,9 @@ lives_ok {
 
     # if isa and does appear together, then see if Class->does(Role)
     # if it does not,.. we have a conflict... so we die loudly
-    ::dies_ok {
+    ::isnt( ::exception {
         has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
-    } '... cannot have a does() which is not done by the isa()';
+    }, undef, '... cannot have a does() which is not done by the isa()' );
 }
 
 {
@@ -95,10 +93,9 @@ lives_ok {
 
     # if isa and does appear together, then see if Class->does(Role)
     # if it does not,.. we have a conflict... so we die loudly
-    ::dies_ok {
+    ::isnt( ::exception {
         has 'foo' => (isa => 'Bling', does => 'Bar::Class');
-    } '... cannot have a isa() which is cannot does()';
+    }, undef, '... cannot have a isa() which is cannot does()' );
 }
 
-
-
+done_testing;