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')
32 # if isa and does appear together, then see if Class->does(Role)
33 # if it does work... then the does() check is actually not needed
34 # since the isa() check will imply the does() check
35 has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role');
43 my $foo = Foo::Class->new;
44 isa_ok($foo, 'Foo::Class');
46 my $bar = Bar::Class->new;
47 isa_ok($bar, 'Bar::Class');
51 }, undef, '... bar passed the type constraint okay' );
55 }, undef, '... foo did not pass the type constraint okay' );
59 }, undef, '... baz passed the type constraint okay' );
63 }, undef, '... foo did not pass the type constraint okay' );
67 }, undef, '... foo passed the type constraint okay' );
71 # some error conditions
77 # if isa and does appear together, then see if Class->does(Role)
78 # if it does not,.. we have a conflict... so we die loudly
80 has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
81 }, undef, '... cannot have a does() which is not done by the isa()' );
89 sub bling { 'Bling::bling' }
94 # if isa and does appear together, then see if Class->does(Role)
95 # if it does not,.. we have a conflict... so we die loudly
97 has 'foo' => (isa => 'Bling', does => 'Bar::Class');
98 }, undef, '... cannot have a isa() which is cannot does()' );