6 use Test::More tests => 9;
14 use Mouse::Util::TypeConstraints;
16 # if does() exists on its own, then
17 # we create a type constraint for
18 # it, just as we do for isa()
19 has 'bar' => (is => 'rw', does => 'Bar::Role');
22 does => role_type('Bar::Role')
28 # if isa and does appear together, then see if Class->does(Role)
29 # if it does work... then the does() check is actually not needed
30 # since the isa() check will imply the does() check
31 has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role');
45 my $foo = Foo::Class->new;
46 isa_ok($foo, 'Foo::Class');
48 my $bar = Bar::Class->new;
49 isa_ok($bar, 'Bar::Class');
53 } '... bar passed the type constraint okay';
57 } '... foo did not pass the type constraint okay';
61 } '... baz passed the type constraint okay';
65 } '... foo did not pass the type constraint okay';
69 } '... foo passed the type constraint okay';
73 # some error conditions
80 local $TODO = 'setting both isa and does';
82 # if isa and does appear together, then see if Class->does(Role)
83 # if it does not,.. we have a conflict... so we die loudly
85 has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
86 } '... cannot have a does() which is not done by the isa()';
94 sub bling { 'Bling::bling' }
100 local $TODO = 'setting both isa and does';
102 # if isa and does appear together, then see if Class->does(Role)
103 # if it does not,.. we have a conflict... so we die loudly
105 has 'foo' => (isa => 'Bling', does => 'Bar::Class');
106 } '... cannot have a isa() which is cannot does()';