Add tests for keys & values delegations
[gitmo/Moose.git] / t / 040_type_constraints / 017_subtyping_union_types.t
index 44ffd95..9b3ae24 100644 (file)
@@ -3,16 +3,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 21;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 
 BEGIN {
     use_ok("Moose::Util::TypeConstraints");
 }
 
-lives_ok {
+is( exception {
     subtype 'MyCollections' => as 'ArrayRef | HashRef';
-} '... created the subtype special okay';
+}, undef, '... created the subtype special okay' );
 
 {
     my $t = find_type_constraint('MyCollections');
@@ -27,23 +27,23 @@ lives_ok {
     is($p->name, 'ArrayRef|HashRef', '... parent name is correct');
 
     ok($t->check([]), '... validated it correctly');
-    ok($t->check({}), '... validated it correctly');    
+    ok($t->check({}), '... validated it correctly');
     ok(!$t->check(1), '... validated it correctly');
 }
 
-lives_ok {
-    subtype 'MyCollectionsExtended' 
+is( exception {
+    subtype 'MyCollectionsExtended'
         => as 'ArrayRef|HashRef'
         => where {
             if (ref($_) eq 'ARRAY') {
                 return if scalar(@$_) < 2;
             }
             elsif (ref($_) eq 'HASH') {
-                return if scalar(keys(%$_)) < 2;                
+                return if scalar(keys(%$_)) < 2;
             }
             1;
         };
-} '... created the subtype special okay';
+}, undef, '... created the subtype special okay' );
 
 {
     my $t = find_type_constraint('MyCollectionsExtended');
@@ -58,12 +58,12 @@ lives_ok {
     is($p->name, 'ArrayRef|HashRef', '... parent name is correct');
 
     ok(!$t->check([]), '... validated it correctly');
-    ok($t->check([1, 2]), '... validated it correctly');    
-    
-    ok(!$t->check({}), '... validated it correctly');    
-    ok($t->check({ one => 1, two => 2 }), '... validated it correctly');    
-    
+    ok($t->check([1, 2]), '... validated it correctly');
+
+    ok(!$t->check({}), '... validated it correctly');
+    ok($t->check({ one => 1, two => 2 }), '... validated it correctly');
+
     ok(!$t->check(1), '... validated it correctly');
 }
 
-
+done_testing;