{
has
'bar'
=> (
is
=>
'rw'
,
does
=>
'Bar::Role'
);
has
'baz'
=> (
is
=>
'rw'
,
does
=> role_type(
'Bar::Role'
)
);
has
'foo'
=> (
is
=>
'rw'
,
isa
=>
'Foo::Class'
,
does
=>
'Foo::Role'
);
}
my
$foo
= Foo::Class->new;
isa_ok(
$foo
,
'Foo::Class'
);
my
$bar
= Bar::Class->new;
isa_ok(
$bar
,
'Bar::Class'
);
is( exception {
$foo
->bar(
$bar
);
},
undef
,
'... bar passed the type constraint okay'
);
isnt( exception {
$foo
->bar(
$foo
);
},
undef
,
'... foo did not pass the type constraint okay'
);
is( exception {
$foo
->baz(
$bar
);
},
undef
,
'... baz passed the type constraint okay'
);
isnt( exception {
$foo
->baz(
$foo
);
},
undef
,
'... foo did not pass the type constraint okay'
);
is( exception {
$bar
->foo(
$foo
);
},
undef
,
'... foo passed the type constraint okay'
);
{
::isnt( ::exception {
has
'foo'
=> (
isa
=>
'Foo::Class'
,
does
=>
'Bar::Class'
);
},
undef
,
'... cannot have a does() which is not done by the isa()'
);
}
{
sub
bling {
'Bling::bling'
}
::isnt( ::exception {
has
'foo'
=> (
isa
=>
'Bling'
,
does
=>
'Bar::Class'
);
},
undef
,
'... cannot have a isa() which is cannot does()'
);
}
done_testing;