2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
13 use_ok("Mouse::Util::TypeConstraints");
17 subtype 'MyCollections' => as 'ArrayRef | HashRef';
18 } '... created the subtype special okay';
21 my $t = find_type_constraint('MyCollections');
22 isa_ok($t, 'Mouse::Meta::TypeConstraint');
24 is($t->name, 'MyCollections', '... name is correct');
27 isa_ok($p, 'Mouse::Meta::TypeConstraint');
28 isa_ok($p, 'Mouse::Meta::TypeConstraint');
30 is($p->name, 'ArrayRef|HashRef', '... parent name is correct');
32 ok($t->check([]), '... validated it correctly');
33 ok($t->check({}), '... validated it correctly');
34 ok(!$t->check(1), '... validated it correctly');
38 subtype 'MyCollectionsExtended'
39 => as 'ArrayRef|HashRef'
41 if (ref($_) eq 'ARRAY') {
42 return if scalar(@$_) < 2;
44 elsif (ref($_) eq 'HASH') {
45 return if scalar(keys(%$_)) < 2;
49 } '... created the subtype special okay';
52 my $t = find_type_constraint('MyCollectionsExtended');
53 isa_ok($t, 'Mouse::Meta::TypeConstraint');
55 is($t->name, 'MyCollectionsExtended', '... name is correct');
58 isa_ok($p, 'Mouse::Meta::TypeConstraint');
59 isa_ok($p, 'Mouse::Meta::TypeConstraint');
61 is($p->name, 'ArrayRef|HashRef', '... parent name is correct');
63 ok(!$t->check([]), '... validated it correctly');
64 ok($t->check([1, 2]), '... validated it correctly');
66 ok(!$t->check({}), '... validated it correctly');
67 ok($t->check({ one => 1, two => 2 }), '... validated it correctly');
69 ok(!$t->check(1), '... validated it correctly');