X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F014_attribute_introspection.t;h=c8a486476f28f44b7d8ea68bd0ad58ff7d3ad123;hb=860f85abed70a4947fb698784aa94252324d770d;hp=7fe3b0ebcbb3aca944d0b73a6f66e64bded47171;hpb=81c8a65bf02bb1b0e240d8f5b626b0ceabf9a37c;p=gitmo%2FClass-MOP.git diff --git a/t/014_attribute_introspection.t b/t/014_attribute_introspection.t index 7fe3b0e..c8a4864 100644 --- a/t/014_attribute_introspection.t +++ b/t/014_attribute_introspection.t @@ -1,14 +1,10 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More tests => 49; +use Test::More tests => 64; use Test::Exception; -BEGIN { - use_ok('Class::MOP'); -} +use Class::MOP; { my $attr = Class::MOP::Attribute->new('$test'); @@ -18,76 +14,90 @@ BEGIN { { my $meta = Class::MOP::Attribute->meta(); isa_ok($meta, 'Class::MOP::Class'); - + my @methods = qw( - meta - new clone - + new + clone + initialize_instance_slot - + _set_initial_slot_value + name - has_accessor accessor - has_writer writer - has_reader reader - has_predicate predicate - has_clearer clearer - has_init_arg init_arg - has_default default is_default_a_coderef - + has_accessor accessor + has_writer writer + has_write_method get_write_method get_write_method_ref + has_reader reader + has_read_method get_read_method get_read_method_ref + has_predicate predicate + has_clearer clearer + has_builder builder + has_init_arg init_arg + has_default default is_default_a_coderef + has_initializer initializer + + definition_context + slots get_value set_value + set_initial_value has_value clear_value - + associated_class - attach_to_class detach_from_class - + attach_to_class + detach_from_class + accessor_metaclass - + associated_methods associate_method - + process_accessors install_accessors remove_accessors + + _new ); - + is_deeply( [ sort $meta->get_method_list ], [ sort @methods ], - '... our method list matches'); - + '... our method list matches'); + foreach my $method_name (@methods) { ok($meta->has_method($method_name), '... Class::MOP::Attribute->has_method(' . $method_name . ')'); } - + my @attributes = ( - '$!name', - '$!accessor', - '$!reader', - '$!writer', - '$!predicate', - '$!clearer', - '$!init_arg', - '$!default', - '$!associated_class', - '@!associated_methods', - ); + 'name', + 'accessor', + 'reader', + 'writer', + 'predicate', + 'clearer', + 'builder', + 'init_arg', + 'initializer', + 'definition_context', + 'default', + 'associated_class', + 'associated_methods', + ); is_deeply( [ sort $meta->get_attribute_list ], [ sort @attributes ], '... our attribute list matches'); - + foreach my $attribute_name (@attributes) { - ok($meta->has_attribute($attribute_name), '... Class::MOP::Attribute->has_attribute(' . $attribute_name . ')'); + ok($meta->has_attribute($attribute_name), '... Class::MOP::Attribute->has_attribute(' . $attribute_name . ')'); } - - # We could add some tests here to make sure that - # the attribute have the appropriate - # accessor/reader/writer/predicate combinations, - # but that is getting a little excessive so I - # wont worry about it for now. Maybe if I get + + # We could add some tests here to make sure that + # the attribute have the appropriate + # accessor/reader/writer/predicate combinations, + # but that is getting a little excessive so I + # wont worry about it for now. Maybe if I get # bored I will do it. }