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