X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2F005_attribute_does.t;h=945717b7b582d079db39f1fc75fcc0ec59825553;hb=203e008eb223539d9149bdd74ac79bbd657e32be;hp=d05a8086d637743a7025ad0b54ab9af998caf339;hpb=e606ae5f848070d889472329819c95f5ba763ca3;p=gitmo%2FMoose.git diff --git a/t/020_attributes/005_attribute_does.t b/t/020_attributes/005_attribute_does.t index d05a808..945717b 100644 --- a/t/020_attributes/005_attribute_does.t +++ b/t/020_attributes/005_attribute_does.t @@ -3,43 +3,41 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More; use Test::Exception; - { package Foo::Role; use Moose::Role; - use Moose::Util::TypeConstraints; + use Moose::Util::TypeConstraints; - # if does() exists on its own, then - # we create a type constraint for + # if does() exists on its own, then + # we create a type constraint for # it, just as we do for isa() - has 'bar' => (is => 'rw', does => 'Bar::Role'); + has 'bar' => (is => 'rw', does => 'Bar::Role'); has 'baz' => ( - is => 'rw', - does => subtype('Role', where { $_->does('Bar::Role') }) - ); + is => 'rw', + does => role_type('Bar::Role') + ); + + package Foo::Class; + use Moose; + + with 'Foo::Role'; package Bar::Role; use Moose::Role; # if isa and does appear together, then see if Class->does(Role) - # if it does work... then the does() check is actually not needed - # since the isa() check will imply the does() check - has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role'); - - package Foo::Class; - use Moose; - - with 'Foo::Role'; + # if it does work... then the does() check is actually not needed + # since the isa() check will imply the does() check + has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role'); package Bar::Class; use Moose; with 'Bar::Role'; - } my $foo = Foo::Class->new; @@ -68,7 +66,7 @@ lives_ok { $bar->foo($foo); } '... foo passed the type constraint okay'; - + # some error conditions @@ -81,15 +79,15 @@ lives_ok { ::dies_ok { has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class'); } '... cannot have a does() which is not done by the isa()'; -} +} { package Bling; use strict; use warnings; - + sub bling { 'Bling::bling' } - + package Bling::Bling; use Moose; @@ -100,5 +98,4 @@ lives_ok { } '... cannot have a isa() which is cannot does()'; } - - +done_testing;