From: Dave Rolsky Date: Wed, 20 Jan 2010 21:50:27 +0000 (-0600) Subject: Tidy code X-Git-Tag: 0.11~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3ced8835a2c0a744e7707022ede02ea4c521871;p=gitmo%2FMooseX-ClassAttribute.git Tidy code --- diff --git a/t/03-introspection.t b/t/03-introspection.t index fa87acf..8c340d3 100644 --- a/t/03-introspection.t +++ b/t/03-introspection.t @@ -8,65 +8,98 @@ use Test::More tests => 14; # We just want the class definitions in here. use SharedTests; +ok( + HasClassAttribute->meta()->has_class_attribute('ObjectCount'), + q{has_class_attribute('ObjectCount') returns true} +); -ok( HasClassAttribute->meta()->has_class_attribute('ObjectCount'), - q{has_class_attribute('ObjectCount') returns true} ); - -ok( HasClassAttribute->meta()->get_class_attribute('ObjectCount') - ->meta()->does_role('MooseX::ClassAttribute::Role::Meta::Attribute'), - 'get_class_attribute_list returns an object which does the MooseX::ClassAttribute::Role::Meta::Attribute role' ); +ok( + HasClassAttribute->meta()->get_class_attribute('ObjectCount')->meta() + ->does_role('MooseX::ClassAttribute::Role::Meta::Attribute'), + 'get_class_attribute_list returns an object which does the MooseX::ClassAttribute::Role::Meta::Attribute role' +); my @ca = qw( Delegatee - LazyAttribute - ManyNames - Mapping - ObjectCount - ReadOnlyAttribute - WeakAttribute - Built - LazyBuilt - Triggerish - ); - -is_deeply( [ sort HasClassAttribute->meta()->get_class_attribute_list() ], - [ sort @ca ], - 'HasClassAttribute get_class_attribute_list gets all class attributes' ); - -is_deeply( [ sort map { $_->name() } HasClassAttribute->meta()->get_all_attributes() ], - [ 'size' ], - 'HasClassAttribute get_all_attributes only finds size attribute' ); - -is_deeply( [ sort map { $_->name() } HasClassAttribute->meta()->get_all_class_attributes() ], - [ sort @ca ], - 'HasClassAttribute get_all_class_attributes gets all class attributes' ); - -is_deeply( [ sort keys %{ HasClassAttribute->meta()->get_class_attribute_map() } ], - [ sort @ca ], - 'HasClassAttribute get_class_attribute_map gets all class attributes' ); - -is_deeply( [ sort map { $_->name() } Child->meta()->get_all_class_attributes() ], - [ sort ( @ca, 'YetAnotherAttribute' ) ], - 'Child get_class_attribute_map gets all class attributes' ); - -ok( ! Child->meta()->has_class_attribute('ObjectCount'), - q{has_class_attribute('ObjectCount') returns false for Child} ); - -ok( Child->meta()->has_class_attribute('YetAnotherAttribute'), - q{has_class_attribute('YetAnotherAttribute') returns true for Child} ); - -ok( Child->can('YetAnotherAttribute'), - 'Child has accessor for YetAnotherAttribute' ); - -ok( Child->meta()->has_class_attribute_value('YetAnotherAttribute'), - 'Child has class attribute value for YetAnotherAttribute' ); + LazyAttribute + ManyNames + Mapping + ObjectCount + ReadOnlyAttribute + WeakAttribute + Built + LazyBuilt + Triggerish +); + +is_deeply( + [ sort HasClassAttribute->meta()->get_class_attribute_list() ], + [ sort @ca ], + 'HasClassAttribute get_class_attribute_list gets all class attributes' +); + +is_deeply( + [ + sort map { $_->name() } + HasClassAttribute->meta()->get_all_attributes() + ], + ['size'], + 'HasClassAttribute get_all_attributes only finds size attribute' +); + +is_deeply( + [ + sort map { $_->name() } + HasClassAttribute->meta()->get_all_class_attributes() + ], + [ sort @ca ], + 'HasClassAttribute get_all_class_attributes gets all class attributes' +); + +is_deeply( + [ sort keys %{ HasClassAttribute->meta()->get_class_attribute_map() } ], + [ sort @ca ], + 'HasClassAttribute get_class_attribute_map gets all class attributes' +); + +is_deeply( + [ sort map { $_->name() } Child->meta()->get_all_class_attributes() ], + [ sort ( @ca, 'YetAnotherAttribute' ) ], + 'Child get_class_attribute_map gets all class attributes' +); + +ok( + !Child->meta()->has_class_attribute('ObjectCount'), + q{has_class_attribute('ObjectCount') returns false for Child} +); + +ok( + Child->meta()->has_class_attribute('YetAnotherAttribute'), + q{has_class_attribute('YetAnotherAttribute') returns true for Child} +); + +ok( + Child->can('YetAnotherAttribute'), + 'Child has accessor for YetAnotherAttribute' +); + +ok( + Child->meta()->has_class_attribute_value('YetAnotherAttribute'), + 'Child has class attribute value for YetAnotherAttribute' +); Child->meta()->remove_class_attribute('YetAnotherAttribute'); -ok( ! Child->meta()->has_class_attribute('YetAnotherAttribute'), - q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute} ); +ok( + !Child->meta()->has_class_attribute('YetAnotherAttribute'), + q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute} +); -ok( ! Child->can('YetAnotherAttribute'), - 'accessor for YetAnotherAttribute has been removed' ); +ok( + !Child->can('YetAnotherAttribute'), + 'accessor for YetAnotherAttribute has been removed' +); -ok( ! Child->meta()->has_class_attribute_value('YetAnotherAttribute'), - 'Child does not have a class attribute value for YetAnotherAttribute' ); +ok( + !Child->meta()->has_class_attribute_value('YetAnotherAttribute'), + 'Child does not have a class attribute value for YetAnotherAttribute' +);