From: Stevan Little Date: Thu, 17 Apr 2008 16:39:56 +0000 (+0000) Subject: perigrin is on crack X-Git-Tag: 0.04~31 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b67a6904179425c08c2810545f8313e51d71c0c;p=gitmo%2FMooseX-MetaDescription.git perigrin is on crack --- diff --git a/t/003_inheriting_meta_desc.t b/t/003_inheriting_meta_desc.t new file mode 100644 index 0000000..561fff3 --- /dev/null +++ b/t/003_inheriting_meta_desc.t @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More no_plan => 1; +use Test::Exception; + +BEGIN { + use_ok('MooseX::MetaDescription'); +} + +{ + package Foo; + use Moose; + + has 'baz' => ( + traits => [ 'MooseX::MetaDescription::Meta::Trait' ], + is => 'ro', + isa => 'Str', + default => sub { 'Foo::baz' }, + description => { + bar => 'Foo::baz::bar', + gorch => 'Foo::baz::gorch', + } + ); + + package Bar; + use Moose; + + extends 'Foo'; +} + +# check the meta-desc + +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 $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; + is($baz_attr, $baz_attr_2, '... got the same attribute'); +} + +# check the actual descs + +foreach my $foo ('Foo', Foo->new, 'Bar', Bar->new) { + + is_deeply( + $foo->meta->find_attribute_by_name('baz')->description, + { + bar => 'Foo::baz::bar', + gorch => 'Foo::baz::gorch', + }, + '... got the right class description' + ); +} \ No newline at end of file