4 use Test::More tests => 16;
10 use Mouse::Util::TypeConstraints 'enum';
12 enum 'Size' => qw(small medium large);
21 use Mouse::Util::TypeConstraints 'enum';
25 isa => enum ['small', 'medium', 'large'],
29 for my $class ('Shirt', 'Shirt::Anon') {
30 ok($class->new(size => 'small'));
31 ok($class->new(size => 'medium'));
32 ok($class->new(size => 'large'));
34 throws_ok { $class->new(size => 'extra small') } qr/^Attribute \(size\) does not pass the type constraint because: Validation failed for '\S+' failed with value extra small/;
35 throws_ok { $class->new(size => 'Small') } qr/^Attribute \(size\) does not pass the type constraint because: Validation failed for '\S+' failed with value Small/;
36 throws_ok { $class->new(size => '') } qr/^Attribute \(size\) does not pass the type constraint because: Validation failed for '\S+' failed with value /;
37 throws_ok { $class->new(size => 'small ') } qr/^Attribute \(size\) does not pass the type constraint because: Validation failed for '\S+' failed with value small /;
38 throws_ok { $class->new(size => ' small') } qr/^Attribute \(size\) does not pass the type constraint because: Validation failed for '\S+' failed with value small/;