X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F014_attribute_introspection.t;h=7b7780370a8cb066d5bd53b722bb1c07654b5edf;hb=8371f3de4e9525ab751008dca4a89e6df65345a6;hp=56467d6cbb21f2885b812cc6a950bc2e8da8bc66;hpb=16e960bd460d404b809a1e5c24ba77405643342b;p=gitmo%2FClass-MOP.git diff --git a/t/014_attribute_introspection.t b/t/014_attribute_introspection.t index 56467d6..7b77803 100644 --- a/t/014_attribute_introspection.t +++ b/t/014_attribute_introspection.t @@ -1,87 +1,128 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More tests => 48; +use Test::More; use Test::Exception; -BEGIN { - use_ok('Class::MOP'); -} +use Class::MOP; { my $attr = Class::MOP::Attribute->new('$test'); - is($attr->meta, Class::MOP::Attribute->meta, '... instance and class both lead to the same meta'); + is( $attr->meta, Class::MOP::Attribute->meta, + '... instance and class both lead to the same meta' ); } { my $meta = Class::MOP::Attribute->meta(); - isa_ok($meta, 'Class::MOP::Class'); - + 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_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 + has_insertion_order insertion_order _set_insertion_order + + definition_context + slots get_value set_value - + get_raw_value + set_raw_value + set_initial_value + has_value + clear_value + associated_class - attach_to_class detach_from_class - - generate_accessor_method - generate_reader_method - generate_writer_method - generate_predicate_method - - generate_accessor_method_inline - generate_reader_method_inline - generate_writer_method_inline - generate_predicate_method_inline - + attach_to_class + detach_from_class + + accessor_metaclass + + associated_methods + associate_method + process_accessors + _process_accessors install_accessors remove_accessors - ); - + + inline_get + inline_set + inline_has + inline_clear + + _new + ); + is_deeply( + [ + sort Class::MOP::Mixin::AttributeCore->meta->get_method_list, + $meta->get_method_list + ], [ sort @methods ], - [ sort $meta->get_method_list ], - '... 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 . ')'); + ok( $meta->find_method_by_name($method_name), + '... Class::MOP::Attribute->find_method_by_name(' . $method_name . ')' ); } - - my @attributes = qw( - name accessor reader writer predicate - init_arg default associated_class - ); + + my @attributes = ( + 'name', + 'accessor', + 'reader', + 'writer', + 'predicate', + 'clearer', + 'builder', + 'init_arg', + 'initializer', + 'definition_context', + 'default', + 'associated_class', + 'associated_methods', + 'insertion_order', + ); is_deeply( + [ + sort Class::MOP::Mixin::AttributeCore->meta->get_attribute_list, + $meta->get_attribute_list + ], [ sort @attributes ], - [ sort $meta->get_attribute_list ], - '... our attribute list matches'); - + '... our attribute list matches' + ); + foreach my $attribute_name (@attributes) { - ok($meta->has_attribute($attribute_name), '... Class::MOP::Attribute->has_attribute(' . $attribute_name . ')'); + ok( $meta->find_attribute_by_name($attribute_name), + '... Class::MOP::Attribute->find_attribute_by_name(' + . $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. } + +done_testing;