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 {
+ok ! exception {
subtype 'MyCollections' => as 'ArrayRef | HashRef';
-} '... created the subtype special okay';
+}, '... created the subtype special okay';
{
my $t = find_type_constraint('MyCollections');
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'
+ok ! 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';
+}, '... created the subtype special okay';
{
my $t = find_type_constraint('MyCollectionsExtended');
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;