Fix error message generation when array or hash ref member fails type check in native...
[gitmo/Moose.git] / t / 020_attributes / 007_attribute_custom_metaclass.t
index a7b8bdb..6985c10 100644 (file)
@@ -3,19 +3,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 17;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 
-BEGIN {
-    use_ok('Moose');           
-}
 
-{    
+{
     package Foo::Meta::Attribute;
     use Moose;
-    
+
     extends 'Moose::Meta::Attribute';
-    
+
     around 'new' => sub {
         my $next = shift;
         my $self = shift;
@@ -25,7 +22,7 @@ BEGIN {
 
     package Foo;
     use Moose;
-    
+
     has 'foo' => (metaclass => 'Foo::Meta::Attribute');
 }
 {
@@ -50,46 +47,46 @@ BEGIN {
 {
     package Bar::Meta::Attribute;
     use Moose;
-    
-    extends 'Class::MOP::Attribute';   
-    
+
+    extends 'Class::MOP::Attribute';
+
     package Bar;
     use Moose;
-    
-    ::lives_ok {
-        has 'bar' => (metaclass => 'Bar::Meta::Attribute');     
-    } '... the attribute metaclass need not be a Moose::Meta::Attribute as long as it behaves';
+
+    ::is( ::exception {
+        has 'bar' => (metaclass => 'Bar::Meta::Attribute');
+    }, undef, '... the attribute metaclass need not be a Moose::Meta::Attribute as long as it behaves' );
 }
 
 {
     package Moose::Meta::Attribute::Custom::Foo;
     sub register_implementation { 'Foo::Meta::Attribute' }
-    
+
     package Moose::Meta::Attribute::Custom::Bar;
     use Moose;
-    
+
     extends 'Moose::Meta::Attribute';
-    
+
     package Another::Foo;
     use Moose;
-    
-    ::lives_ok {
-        has 'foo' => (metaclass => 'Foo');    
-    } '... the attribute metaclass alias worked correctly';
-    
-    ::lives_ok {
-        has 'bar' => (metaclass => 'Bar');    
-    } '... the attribute metaclass alias worked correctly';    
+
+    ::is( ::exception {
+        has 'foo' => (metaclass => 'Foo');
+    }, undef, '... the attribute metaclass alias worked correctly' );
+
+    ::is( ::exception {
+        has 'bar' => (metaclass => 'Bar', is => 'bare');
+    }, undef, '... the attribute metaclass alias worked correctly' );
 }
 
 {
     my $foo_attr = Another::Foo->meta->get_attribute('foo');
     isa_ok($foo_attr, 'Foo::Meta::Attribute');
     isa_ok($foo_attr, 'Moose::Meta::Attribute');
-    
+
     my $bar_attr = Another::Foo->meta->get_attribute('bar');
     isa_ok($bar_attr, 'Moose::Meta::Attribute::Custom::Bar');
-    isa_ok($bar_attr, 'Moose::Meta::Attribute');    
+    isa_ok($bar_attr, 'Moose::Meta::Attribute');
 }
 
-
+done_testing;