X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F005_attributes.t;h=9615c0bff1811c033f3a329d66423af7fac4b7b8;hb=c9e77dbb017258dc44295fc4ec8e0bdd99ec9361;hp=0779a772612f49cf773e335dcbe5be1df14d9b29;hpb=677eb1584b6e27c6079daed35110cb4192153db4;p=gitmo%2FClass-MOP.git diff --git a/t/005_attributes.t b/t/005_attributes.t index 0779a77..9615c0b 100644 --- a/t/005_attributes.t +++ b/t/005_attributes.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 30; +use Test::More tests => 33; use Test::Exception; BEGIN { @@ -68,25 +68,18 @@ my $BAZ_ATTR = Class::MOP::Attribute->new('$baz' => ( isa_ok($meta, 'Class::MOP::Class'); is_deeply( - [ sort { $a->{name} cmp $b->{name} } $meta->compute_all_applicable_attributes() ], + [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], [ - { - name => '$bar', - class => 'Bar', - attribute => $BAR_ATTR - }, - { - name => '$baz', - class => 'Baz', - attribute => $BAZ_ATTR - }, - { - name => '$foo', - class => 'Foo', - attribute => $FOO_ATTR - }, + $BAR_ATTR, + $BAZ_ATTR, + $FOO_ATTR, ], '... got the right list of applicable attributes for Baz'); + + is_deeply( + [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], + [ Bar->meta, Baz->meta, Foo->meta ], + '... got the right list of associated classes from the applicable attributes for Baz'); my $attr; lives_ok { @@ -100,21 +93,18 @@ my $BAZ_ATTR = Class::MOP::Attribute->new('$baz' => ( ok(!$meta->has_method('set_baz'), '... a writer has been removed'); is_deeply( - [ sort { $a->{name} cmp $b->{name} } $meta->compute_all_applicable_attributes() ], + [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], [ - { - name => '$bar', - class => 'Bar', - attribute => $BAR_ATTR - }, - { - name => '$foo', - class => 'Foo', - attribute => $FOO_ATTR - }, + $BAR_ATTR, + $FOO_ATTR, ], '... got the right list of applicable attributes for Baz'); + is_deeply( + [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], + [ Bar->meta, Foo->meta ], + '... got the right list of associated classes from the applicable attributes for Baz'); + { my $attr; lives_ok { @@ -128,14 +118,15 @@ my $BAZ_ATTR = Class::MOP::Attribute->new('$baz' => ( } is_deeply( - [ sort { $a->{name} cmp $b->{name} } $meta->compute_all_applicable_attributes() ], + [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], [ - { - name => '$foo', - class => 'Foo', - attribute => $FOO_ATTR - }, + $FOO_ATTR, ], '... got the right list of applicable attributes for Baz'); + is_deeply( + [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], + [ Foo->meta ], + '... got the right list of associated classes from the applicable attributes for Baz'); + }