Test coercion of lazy defaults
[gitmo/Moose.git] / t / 030_roles / 016_runtime_roles_and_nonmoose.t
index 706018d..2317688 100644 (file)
@@ -3,14 +3,10 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 use Scalar::Util 'blessed';
 
-BEGIN {
-    use_ok('Moose');
-}
-
 
 {
     package Dog;
@@ -35,24 +31,26 @@ BEGIN {
     }
 }
 
-my $obj = Bar->new;
-isa_ok($obj, 'Bar');    
+my $bar = Bar->new;
+isa_ok($bar, 'Bar');
 
 my $foo = Foo->new;
+isa_ok($foo, 'Foo');
 
-ok(!$obj->can( 'talk' ), "... the role is not composed yet");
+ok(!$bar->can( 'talk' ), "... the role is not composed yet");
 
-dies_ok {
-    $foo->dog($obj)
-} '... and setting the accessor fails (not a Dog yet)';
+isnt( exception {
+    $foo->dog($bar)
+}, undef, '... and setting the accessor fails (not a Dog yet)' );
 
-Dog->meta->apply($obj);
+Dog->meta->apply($bar);
 
-ok($obj->can('talk'), "... the role is now composed at the object level");
+ok($bar->can('talk'), "... the role is now composed at the object level");
 
-is($obj->talk, 'woof', '... got the right return value for the newly composed method');
+is($bar->talk, 'woof', '... got the right return value for the newly composed method');
 
-lives_ok {
-    $foo->dog($obj)
-} '... and setting the accessor is okay';
+is( exception {
+    $foo->dog($bar)
+}, undef, '... and setting the accessor is okay' );
 
+done_testing;