From: Stevan Little Date: Thu, 17 Apr 2008 16:48:35 +0000 (+0000) Subject: adding more tests X-Git-Tag: 0.04~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fb835cf8090355016bc595ddf82d317086764f5d;p=gitmo%2FMooseX-MetaDescription.git adding more tests --- 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',