X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2F009_attribute_inherited_slot_specs.t;h=71bc254f36148686dd4465add8ac20d77c8687c5;hb=4d438a84f437bcb3c43a04c27823b8b431cd3f55;hp=7903f9d9b7711772e4059c36f42d3918acb1c6bf;hpb=ae907ae0d11773f6913e16f9430e47ce6417646f;p=gitmo%2FMoose.git diff --git a/t/020_attributes/009_attribute_inherited_slot_specs.t b/t/020_attributes/009_attribute_inherited_slot_specs.t index 7903f9d..71bc254 100644 --- a/t/020_attributes/009_attribute_inherited_slot_specs.t +++ b/t/020_attributes/009_attribute_inherited_slot_specs.t @@ -3,12 +3,19 @@ use strict; use warnings; -use Test::More tests => 84; +use Test::More; use Test::Exception; - { + package Thing::Meta::Attribute; + use Moose; + + extends 'Moose::Meta::Attribute'; + around illegal_options_for_inheritance => sub { + return (shift->(@_), qw/trigger/); + }; + package Thing; use Moose; @@ -33,6 +40,7 @@ use Test::Exception; has 'gorch' => (is => 'ro'); has 'gloum' => (is => 'ro', default => sub {[]}); + has 'fleem' => (is => 'ro'); has 'bling' => (is => 'ro', isa => 'Thing'); has 'blang' => (is => 'ro', isa => 'Thing', handles => ['goodbye']); @@ -43,7 +51,7 @@ use Test::Exception; # this one will work here .... has 'fail' => (isa => 'CodeRef', is => 'bare'); - has 'other_fail' => (is => 'bare'); + has 'other_fail' => (metaclass => 'Thing::Meta::Attribute', is => 'bare', trigger => sub { }); package Bar; use Moose; @@ -88,6 +96,10 @@ use Test::Exception; } '... now can extend an attribute with a non-subtype'; ::lives_ok { + has '+fleem' => (weak_ref => 1); + } '... now allowed to add the weak_ref option via inheritance'; + + ::lives_ok { has '+bling' => (handles => ['hello']); } '... we can add the handles attribute option'; @@ -101,9 +113,6 @@ use Test::Exception; ::dies_ok { has '+other_fail' => (trigger => sub {}); } '... cannot create an attribute with an illegal option'; - ::dies_ok { - has '+other_fail' => (weak_ref => 1); - } '... cannot create an attribute with an illegal option'; ::throws_ok { has '+does_not_exist' => (isa => 'Str'); } qr/in Bar/, '... cannot extend a non-existing attribute'; @@ -259,4 +268,4 @@ ok(!Foo->meta->get_attribute('bling')->has_handles, ok(Bar->meta->get_attribute('bling')->has_handles, '... Bar::foo should handles'); - +done_testing;