X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F005_attributes.t;h=b7a545b95cab5def8bd16d0477846ac549136739;hb=d83eddd0c97e4828272ea7a174731437ac36ebf1;hp=dad4d5420d9e58ab3ae4e47eb7a797596c5a49c5;hpb=ffba6596d5bace4e80edf9846463053add25220a;p=gitmo%2FClass-MOP.git diff --git a/t/005_attributes.t b/t/005_attributes.t index dad4d54..b7a545b 100644 --- a/t/005_attributes.t +++ b/t/005_attributes.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 73; +use Test::More tests => 90; use Test::Exception; use Class::MOP; @@ -113,7 +113,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); is($meta->find_attribute_by_name('$foo'), $FOO_ATTR, '... got the right attribute for "foo"'); is_deeply( - [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], + [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ], [ $BAR_ATTR, $BAZ_ATTR, @@ -122,7 +122,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); '... 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() ], + [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ], [ Bar->meta, Baz->meta, Foo->meta ], '... got the right list of associated classes from the applicable attributes for Baz'); @@ -139,7 +139,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); 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->get_all_attributes() ], [ $BAR_ATTR, $FOO_ATTR, @@ -147,7 +147,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); '... 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() ], + [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ], [ Bar->meta, Foo->meta ], '... got the right list of associated classes from the applicable attributes for Baz'); @@ -164,7 +164,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); } is_deeply( - [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ], + [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ], [ $BAR_ATTR_2, $FOO_ATTR, @@ -172,7 +172,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); '... 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() ], + [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ], [ Foo->meta, Foo->meta ], '... got the right list of associated classes from the applicable attributes for Baz'); @@ -225,7 +225,9 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); } '... we added a method to Buzz successfully'; } -{ + + +for(1 .. 2){ my $buzz; ::lives_ok { $buzz = Buzz->meta->new_object } '...Buzz instantiated successfully'; ::is($buzz->foo, 'Buzz', '...foo builder works as expected'); @@ -244,17 +246,15 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); ::ok($buzz2->has_bar, '...bar is set'); ::is($buzz2->bar, undef, '...bar is undef'); -} + my $buzz3; + ::lives_ok { $buzz3 = Buzz->meta->new_object } '...Buzz instantiated successfully'; + ::ok($buzz3->has_bah, '...bah is set'); + ::is($buzz3->bah, 'BAH', '...bah returns "BAH" '); -{ - my $buzz; - ::lives_ok { $buzz = Buzz->meta->new_object } '...Buzz instantiated successfully'; - ::ok($buzz->has_bah, '...bah is set'); - ::is($buzz->bah, 'BAH', '...bah returns "BAH" '); - - my $buzz2; - ::lives_ok { $buzz2 = Buzz->meta->new_object('$bah' => undef) } '...Buzz instantiated successfully'; - ::ok($buzz2->has_bah, '...bah is set'); - ::is($buzz2->bah, undef, '...bah is undef'); + my $buzz4; + ::lives_ok { $buzz4 = Buzz->meta->new_object('$bah' => undef) } '...Buzz instantiated successfully'; + ::ok($buzz4->has_bah, '...bah is set'); + ::is($buzz4->bah, undef, '...bah is undef'); + Buzz->meta->make_immutable(); }