13 use Moose::Util::TypeConstraints;
15 # if does() exists on its own, then
16 # we create a type constraint for
17 # it, just as we do for isa()
18 has 'bar' => (is => 'rw', does => 'Bar::Role');
21 does => role_type('Bar::Role')
27 # if isa and does appear together, then see if Class->does(Role)
28 # if it does work... then the does() check is actually not needed
29 # since the isa() check will imply the does() check
30 has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role');
44 my $foo = Foo::Class->new;
45 isa_ok($foo, 'Foo::Class');
47 my $bar = Bar::Class->new;
48 isa_ok($bar, 'Bar::Class');
52 } '... bar passed the type constraint okay';
56 } '... foo did not pass the type constraint okay';
60 } '... baz passed the type constraint okay';
64 } '... foo did not pass the type constraint okay';
68 } '... foo passed the type constraint okay';
72 # some error conditions
78 # if isa and does appear together, then see if Class->does(Role)
79 # if it does not,.. we have a conflict... so we die loudly
81 has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
82 } '... cannot have a does() which is not done by the isa()';
90 sub bling { 'Bling::bling' }
95 # if isa and does appear together, then see if Class->does(Role)
96 # if it does not,.. we have a conflict... so we die loudly
98 has 'foo' => (isa => 'Bling', does => 'Bar::Class');
99 } '... cannot have a isa() which is cannot does()';