X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F003_inheriting_meta_desc.t;h=a4ced5a9a03b9f21422ab57e23c25029413d940f;hb=fb835cf8090355016bc595ddf82d317086764f5d;hp=561fff370aa5616a798d62e749c8f9c94b784a63;hpb=4b67a6904179425c08c2810545f8313e51d71c0c;p=gitmo%2FMooseX-MetaDescription.git diff --git a/t/003_inheriting_meta_desc.t b/t/003_inheriting_meta_desc.t index 561fff3..a4ced5a 100644 --- a/t/003_inheriting_meta_desc.t +++ b/t/003_inheriting_meta_desc.t @@ -14,6 +14,17 @@ BEGIN { package Foo; use Moose; + has 'bar' => ( + metaclass => 'MooseX::MetaDescription::Meta::Attribute', + is => 'ro', + isa => 'Str', + default => sub { 'Foo::bar' }, + description => { + baz => 'Foo::bar::baz', + gorch => 'Foo::bar::gorch', + } + ); + has 'baz' => ( traits => [ 'MooseX::MetaDescription::Meta::Trait' ], is => 'ro', @@ -33,17 +44,30 @@ BEGIN { # check the meta-desc +my $bar_attr = Foo->meta->find_attribute_by_name('bar'); +isa_ok($bar_attr->metadescription, 'MooseX::MetaDescription::Description'); +is($bar_attr->metadescription->descriptor, $bar_attr, '... got the circular ref'); + my $baz_attr = Foo->meta->find_attribute_by_name('baz'); isa_ok($baz_attr->metadescription, 'MooseX::MetaDescription::Description'); is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref'); { + + my $bar_attr = Bar->meta->find_attribute_by_name('bar'); + + can_ok($bar_attr, 'description'); + isa_ok($bar_attr->metadescription, 'MooseX::MetaDescription::Description'); + is($bar_attr->metadescription->descriptor, $bar_attr, '... got the circular ref'); + my $baz_attr = Bar->meta->find_attribute_by_name('baz'); + can_ok($baz_attr, 'description'); isa_ok($baz_attr->metadescription, 'MooseX::MetaDescription::Description'); is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref'); - my ($baz_attr_2) = Bar->meta->compute_all_applicable_attributes; + my ($bar_attr_2, $baz_attr_2) = Bar->meta->compute_all_applicable_attributes; + is($bar_attr, $bar_attr_2, '... got the same attribute'); is($baz_attr, $baz_attr_2, '... got the same attribute'); } @@ -52,6 +76,15 @@ is($baz_attr->metadescription->descriptor, $baz_attr, '... got the circular ref' foreach my $foo ('Foo', Foo->new, 'Bar', Bar->new) { is_deeply( + $foo->meta->find_attribute_by_name('bar')->description, + { + baz => 'Foo::bar::baz', + gorch => 'Foo::bar::gorch', + }, + '... got the right class description' + ); + + is_deeply( $foo->meta->find_attribute_by_name('baz')->description, { bar => 'Foo::baz::bar',