X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2F005_attribute_does.t;h=8161537c426a1a42281d95668bbc8e7a296336e6;hb=4875754294c3a5b0d5453f20f1a19fb737c3c851;hp=06dd05f94e1d719bd7890ab2380741407f351d94;hpb=e59a5c292a333cac504b65ebd4bba20b5e98d796;p=gitmo%2FMoose.git diff --git a/t/020_attributes/005_attribute_does.t b/t/020_attributes/005_attribute_does.t index 06dd05f..8161537 100644 --- a/t/020_attributes/005_attribute_does.t +++ b/t/020_attributes/005_attribute_does.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 10; use Test::Exception; BEGIN { @@ -13,11 +13,16 @@ BEGIN { { package Foo::Role; use Moose::Role; + use Moose::Util::TypeConstraints; # 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 'baz' => ( + is => 'rw', + does => subtype('Role', where { $_->does('Bar::Role') }) + ); package Bar::Role; use Moose::Role; @@ -54,8 +59,18 @@ dies_ok { } '... foo did not pass the type constraint okay'; lives_ok { + $foo->baz($bar); +} '... baz passed the type constraint okay'; + +dies_ok { + $foo->baz($foo); +} '... foo did not pass the type constraint okay'; + +lives_ok { $bar->foo($foo); -} '... foo passed the type constraint okay'; +} '... foo passed the type constraint okay'; + + # some error conditions