4 use Test::More tests => 14;
7 use Mouse::Util::TypeConstraints;
12 use Mouse::Util::TypeConstraints;
16 => where { length $_ }
17 => message { "The string is empty!" };
21 => where { $_->isa(__PACKAGE__) };
29 ok(My::Class->new(name => 'foo'));
31 throws_ok { My::Class->new(name => '') } qr/^Attribute \(name\) does not pass the type constraint because: The string is empty!/;
33 my $st = subtype as 'Str', where{ length };
35 ok $st->is_a_type_of('Str');
36 ok!$st->is_a_type_of('NoemptyStr');
43 my $tc = find_type_constraint('MyClass');
44 ok $tc->check(My::Class->new());
45 ok!$tc->check('My::Class');
51 use Mouse::Util::TypeConstraints;
53 $st = subtype as 'Int', where{ $_ > 0 };
55 ::ok $st->is_a_type_of('Int');