Redid conversion to Test::Fatal
[gitmo/Moose.git] / t / 020_attributes / 023_attribute_names.t
index f63b948..2a10043 100644 (file)
@@ -2,28 +2,58 @@
 
 use strict;
 use warnings;
-use Test::More tests => 8;
-use Test::Exception;
-
-# note: not sure about "" and 0 being illegal attribute names
-# but I'm just copying what Class::MOP::Attribute does
+use Test::More;
+use Test::Fatal;
 
 my $exception_regex = qr/You must provide a name for the attribute/;
 {
     package My::Role;
     use Moose::Role;
-    ::throws_ok{ has;       } $exception_regex, 'has; fails';
-    ::throws_ok{ has undef; } $exception_regex, 'has undef; fails';
-    ::throws_ok{ has "";    } $exception_regex, 'has ""; fails';
-    ::throws_ok{ has 0;     } $exception_regex, 'has 0; fails';
+
+    ::like( ::exception {
+        has;
+    }, $exception_regex, 'has; fails' );
+
+    ::like( ::exception {
+        has undef;
+    }, $exception_regex, 'has undef; fails' );
+
+    ::is( ::exception {
+        has "" => (
+            is => 'bare',
+        );
+    }, undef, 'has ""; works now' );
+
+    ::is( ::exception {
+        has 0 => (
+            is => 'bare',
+        );
+    }, undef, 'has 0; works now' );
 }
 
 {
     package My::Class;
     use Moose;
-    ::throws_ok{ has;       } $exception_regex, 'has; fails';
-    ::throws_ok{ has undef; } $exception_regex, 'has undef; fails';
-    ::throws_ok{ has "";    } $exception_regex, 'has ""; fails';
-    ::throws_ok{ has 0;     } $exception_regex, 'has 0; fails';
+
+    ::like( ::exception {
+        has;
+    }, $exception_regex, 'has; fails' );
+
+    ::like( ::exception {
+        has undef;
+    }, $exception_regex, 'has undef; fails' );
+
+    ::is( ::exception {
+        has "" => (
+            is => 'bare',
+        );
+    }, undef, 'has ""; works now' );
+
+    ::is( ::exception {
+        has 0 => (
+            is => 'bare',
+        );
+    }, undef, 'has 0; works now' );
 }
 
+done_testing;