Redid conversion to Test::Fatal
[gitmo/Moose.git] / t / 030_roles / 013_method_aliasing_in_composition.t
index cbe8bf1..c6146a7 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use Test::More;
-use Test::Exception;
+use Test::Fatal;
 
 
 {
@@ -20,16 +20,16 @@ use Test::Exception;
     package My::Class;
     use Moose;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'My::Role' => { -alias => { bar => 'role_bar' } };
-    } '... this succeeds';
+    }, undef, '... this succeeds' );
 
     package My::Class::Failure;
     use Moose;
 
-    ::throws_ok {
+    ::like( ::exception {
         with 'My::Role' => { -alias => { bar => 'role_bar' } };
-    } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds';
+    }, qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds' );
 
     sub role_bar { 'FAIL' }
 }
@@ -40,18 +40,18 @@ ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz bar ro
     package My::OtherRole;
     use Moose::Role;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'My::Role' => { -alias => { bar => 'role_bar' } };
-    } '... this succeeds';
+    }, undef, '... this succeeds' );
 
     sub bar { 'My::OtherRole::bar' }
 
     package My::OtherRole::Failure;
     use Moose::Role;
 
-    ::throws_ok {
+    ::like( ::exception {
         with 'My::Role' => { -alias => { bar => 'role_bar' } };
-    } qr/Cannot create a method alias if a local method of the same name exists/, '... cannot alias to a name that exists';
+    }, qr/Cannot create a method alias if a local method of the same name exists/, '... cannot alias to a name that exists' );
 
     sub role_bar { 'FAIL' }
 }
@@ -64,9 +64,9 @@ ok(!My::OtherRole->meta->requires_method('role_bar'), '... and the &role_bar met
     package My::AliasingRole;
     use Moose::Role;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'My::Role' => { -alias => { bar => 'role_bar' } };
-    } '... this succeeds';
+    }, undef, '... this succeeds' );
 }
 
 ok(My::AliasingRole->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar);
@@ -91,21 +91,20 @@ ok(!My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is
     package My::Foo::Class;
     use Moose;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' },
              'Bar::Role' => { -alias => { 'foo' => 'bar_foo' }, -excludes => 'foo' },
              'Baz::Role';
-    } '... composed our roles correctly';
+    }, undef, '... composed our roles correctly' );
 
     package My::Foo::Class::Broken;
     use Moose;
 
-    ::throws_ok {
+    ::like( ::exception {
         with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' },
              'Bar::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' },
              'Baz::Role';
-    } qr/Due to a method name conflict in roles 'Bar::Role' and 'Foo::Role', the method 'foo_foo' must be implemented or excluded by 'My::Foo::Class::Broken'/,
-      '... composed our roles correctly';
+    }, qr/Due to a method name conflict in roles 'Bar::Role' and 'Foo::Role', the method 'foo_foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, '... composed our roles correctly' );
 }
 
 {
@@ -121,11 +120,11 @@ ok(!My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is
     package My::Foo::Role;
     use Moose::Role;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' },
              'Bar::Role' => { -alias => { 'foo' => 'bar_foo' }, -excludes => 'foo' },
              'Baz::Role';
-    } '... composed our roles correctly';
+    }, undef, '... composed our roles correctly' );
 }
 
 ok(My::Foo::Role->meta->has_method($_), "we have a $_ method") for qw/foo foo_foo bar_foo/;;
@@ -136,11 +135,11 @@ ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not
     package My::Foo::Role::Other;
     use Moose::Role;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' },
              'Bar::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' },
              'Baz::Role';
-    } '... composed our roles correctly';
+    }, undef, '... composed our roles correctly' );
 }
 
 ok(!My::Foo::Role::Other->meta->has_method('foo_foo'), "we dont have a foo_foo method");
@@ -150,9 +149,9 @@ ok(My::Foo::Role::Other->meta->requires_method('foo_foo'), '... and the &foo met
     package My::Foo::AliasOnly;
     use Moose;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' } },
-    } '... composed our roles correctly';
+    }, undef, '... composed our roles correctly' );
 }
 
 ok(My::Foo::AliasOnly->meta->has_method('foo'), 'we have a foo method');
@@ -170,13 +169,12 @@ ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo
     package Role::Bar;
     use Moose::Role;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'Role::Foo' => {
             -alias    => { x1 => 'foo_x1' },
             -excludes => ['y1'],
         };
-    }
-    'Compose Role::Foo into Role::Bar with alias and exclude';
+    }, undef, 'Compose Role::Foo into Role::Bar with alias and exclude' );
 
     sub x1 {}
     sub y1 {}
@@ -192,13 +190,12 @@ ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo
     package Role::Baz;
     use Moose::Role;
 
-    ::lives_ok {
+    ::is( ::exception {
         with 'Role::Foo' => {
             -alias    => { x1 => 'foo_x1' },
             -excludes => ['y1'],
         };
-    }
-    'Compose Role::Foo into Role::Baz with alias and exclude';
+    }, undef, 'Compose Role::Foo into Role::Baz with alias and exclude' );
 }
 
 {