Redid conversion to Test::Fatal
[gitmo/Moose.git] / t / 050_metaclasses / 013_metaclass_traits.t
index a78ea4c..a96d95e 100644 (file)
@@ -5,8 +5,8 @@ use warnings;
 
 use lib 't/lib', 'lib';
 
-use Test::More tests => 31;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 
 {
     package My::SimpleTrait;
@@ -167,10 +167,14 @@ is( Role::Foo->meta()->simple(), 5,
 
 {
     require Moose::Util::TypeConstraints;
-    dies_ok( sub { Moose::Util::TypeConstraints->import( -traits => 'My::SimpleTrait' ) },
-             'cannot provide -traits to an exporting module that does not init_meta' );
-    like( $@, qr/does not have an init_meta/,
-          '... and error provides a useful explanation' );
+    like(
+        exception {
+            Moose::Util::TypeConstraints->import(
+                -traits => 'My::SimpleTrait' );
+        },
+        qr/does not have an init_meta/,
+        'cannot provide -traits to an exporting module that does not init_meta'
+    );
 }
 
 {
@@ -191,29 +195,32 @@ is( Foo::Subclass->meta()->attr2(), 'something',
     'Foo::Subclass->meta()->attr2() returns expected value' );
 
 {
+
     package Class::WithAlreadyPresentTrait;
     use Moose -traits => 'My::SimpleTrait';
 
-   has an_attr => ( is => 'ro' );
+    has an_attr => ( is => 'ro' );
 }
-lives_ok {
-    my $instance = Class::WithAlreadyPresentTrait->new(an_attr => 'value');
-    is($instance->an_attr, 'value', 'Can get value');
-} 'Can create instance and access attributes';
+
+is( exception {
+    my $instance = Class::WithAlreadyPresentTrait->new( an_attr => 'value' );
+    is( $instance->an_attr, 'value', 'Can get value' );
+}, undef, 'Can create instance and access attributes' );
 
 {
+
     package Class::WhichLoadsATraitFromDisk;
-    use Moose -traits => 'Role::Parent'; # Any role you like here, the only important bit is that it
-                                         # gets loaded from disk and has not already been defined.
-    
+
+    # Any role you like here, the only important bit is that it gets
+    # loaded from disk and has not already been defined.
+    use Moose -traits => 'Role::Parent';
+
     has an_attr => ( is => 'ro' );
 }
 
-TODO: {
-    local $TODO = 'Not working yet';
-    lives_ok {
-        my $instance = Class::WhichLoadsATraitFromDisk->new(an_attr => 'value');
-        is($instance->an_attr, 'value', 'Can get value');
-    } 'Can create instance and access attributes';
-}
+is( exception {
+    my $instance = Class::WhichLoadsATraitFromDisk->new( an_attr => 'value' );
+    is( $instance->an_attr, 'value', 'Can get value' );
+}, undef, 'Can create instance and access attributes' );
 
+done_testing;