6 use Test::More tests => 19;
\r
10 use_ok("Mouse::Util::TypeConstraints");
\r
14 subtype 'MyCollections' => as 'ArrayRef | HashRef';
\r
15 } '... created the subtype special okay';
\r
18 my $t = find_type_constraint('MyCollections');
\r
19 isa_ok($t, 'Mouse::Meta::TypeConstraint');
\r
21 is($t->name, 'MyCollections', '... name is correct');
\r
24 # isa_ok($p, 'Mouse::Meta::TypeConstraint::Union');
\r
25 isa_ok($p, 'Mouse::Meta::TypeConstraint');
\r
27 is($p->name, 'ArrayRef|HashRef', '... parent name is correct');
\r
29 ok($t->check([]), '... validated it correctly');
\r
30 ok($t->check({}), '... validated it correctly');
\r
31 ok(!$t->check(1), '... validated it correctly');
\r
35 subtype 'MyCollectionsExtended'
\r
36 => as 'ArrayRef|HashRef'
\r
38 if (ref($_) eq 'ARRAY') {
\r
39 return if scalar(@$_) < 2;
\r
41 elsif (ref($_) eq 'HASH') {
\r
42 return if scalar(keys(%$_)) < 2;
\r
46 } '... created the subtype special okay';
\r
49 my $t = find_type_constraint('MyCollectionsExtended');
\r
50 isa_ok($t, 'Mouse::Meta::TypeConstraint');
\r
52 is($t->name, 'MyCollectionsExtended', '... name is correct');
\r
55 # isa_ok($p, 'Mouse::Meta::TypeConstraint::Union');
\r
56 isa_ok($p, 'Mouse::Meta::TypeConstraint');
\r
58 is($p->name, 'ArrayRef|HashRef', '... parent name is correct');
\r
60 ok(!$t->check([]), '... validated it correctly');
\r
61 ok($t->check([1, 2]), '... validated it correctly');
\r
63 ok(!$t->check({}), '... validated it correctly');
\r
64 ok($t->check({ one => 1, two => 2 }), '... validated it correctly');
\r
66 ok(!$t->check(1), '... validated it correctly');
\r