X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F010_self_introspection.t;h=5751cbe076d89cbb1d988400af74861f59f2ce6e;hb=d5f6699d736fb63d5c072400969e366edabe8efd;hp=48e6ab6c5b9ad1b2cd3bc2b0ebfc1852a79af4d9;hpb=abfebb5208f2548ec481bd2db36d1505f77fb180;p=gitmo%2FClass-MOP.git diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index 48e6ab6..5751cbe 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -1,17 +1,13 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More tests => 236; +use Test::More tests => 246; use Test::Exception; -BEGIN { - use_ok('Class::MOP'); - use_ok('Class::MOP::Class'); - use_ok('Class::MOP::Package'); - use_ok('Class::MOP::Module'); -} +use Class::MOP; +use Class::MOP::Class; +use Class::MOP::Package; +use Class::MOP::Module; { my $class = Class::MOP::Class->initialize('Foo'); @@ -44,7 +40,7 @@ my @class_mop_package_methods = qw( my @class_mop_module_methods = qw( _new - version authority identifier + version authority identifier create ); my @class_mop_class_methods = qw( @@ -70,12 +66,12 @@ my @class_mop_class_methods = qw( add_dependent_meta_instance remove_dependent_meta_instance invalidate_meta_instances invalidate_meta_instance - attribute_metaclass method_metaclass + attribute_metaclass method_metaclass wrapped_method_metaclass superclasses subclasses class_precedence_list linearized_isa has_method get_method add_method remove_method alias_method wrap_method_body - get_method_list get_method_map get_all_methods compute_all_applicable_methods + get_method_list get_method_map get_all_method_names get_all_methods compute_all_applicable_methods find_method_by_name find_all_methods_by_name find_next_method_by_name add_before_method_modifier add_after_method_modifier add_around_method_modifier @@ -91,9 +87,9 @@ my @class_mop_class_methods = qw( # check the class ... -is_deeply([ sort @class_mop_class_methods ], [ sort $class_mop_class_meta->get_method_list ], '... got the correct method list for class'); +is_deeply([ sort $class_mop_class_meta->get_method_list ], [ sort @class_mop_class_methods ], '... got the correct method list for class'); -foreach my $method_name (@class_mop_class_methods) { +foreach my $method_name (sort @class_mop_class_methods) { ok($class_mop_class_meta->has_method($method_name), '... Class::MOP::Class->has_method(' . $method_name . ')'); { no strict 'refs'; @@ -105,9 +101,9 @@ foreach my $method_name (@class_mop_class_methods) { ## check the package .... -is_deeply([ sort @class_mop_package_methods ], [ sort $class_mop_package_meta->get_method_list ], '... got the correct method list for package'); +is_deeply([ sort $class_mop_package_meta->get_method_list ], [ sort @class_mop_package_methods ], '... got the correct method list for package'); -foreach my $method_name (@class_mop_package_methods) { +foreach my $method_name (sort @class_mop_package_methods) { ok($class_mop_package_meta->has_method($method_name), '... Class::MOP::Package->has_method(' . $method_name . ')'); { no strict 'refs'; @@ -119,9 +115,9 @@ foreach my $method_name (@class_mop_package_methods) { ## check the module .... -is_deeply([ sort @class_mop_module_methods ], [ sort $class_mop_module_meta->get_method_list ], '... got the correct method list for module'); +is_deeply([ sort $class_mop_module_meta->get_method_list ], [ sort @class_mop_module_methods ], '... got the correct method list for module'); -foreach my $method_name (@class_mop_module_methods) { +foreach my $method_name (sort @class_mop_module_methods) { ok($class_mop_module_meta->has_method($method_name), '... Class::MOP::Module->has_method(' . $method_name . ')'); { no strict 'refs'; @@ -161,22 +157,24 @@ my @class_mop_class_attributes = ( 'attributes', 'attribute_metaclass', 'method_metaclass', + 'wrapped_method_metaclass', 'instance_metaclass' ); # check class is_deeply( - [ sort @class_mop_class_attributes ], [ sort $class_mop_class_meta->get_attribute_list ], - '... got the right list of attributes'); + [ sort @class_mop_class_attributes ], + '... got the right list of attributes' +); is_deeply( - [ sort @class_mop_class_attributes ], [ sort keys %{$class_mop_class_meta->get_attribute_map} ], + [ sort @class_mop_class_attributes ], '... got the right list of attributes'); -foreach my $attribute_name (@class_mop_class_attributes) { +foreach my $attribute_name (sort @class_mop_class_attributes) { ok($class_mop_class_meta->has_attribute($attribute_name), '... Class::MOP::Class->has_attribute(' . $attribute_name . ')'); isa_ok($class_mop_class_meta->get_attribute($attribute_name), 'Class::MOP::Attribute'); } @@ -184,16 +182,16 @@ foreach my $attribute_name (@class_mop_class_attributes) { # check module is_deeply( - [ sort @class_mop_package_attributes ], [ sort $class_mop_package_meta->get_attribute_list ], + [ sort @class_mop_package_attributes ], '... got the right list of attributes'); is_deeply( - [ sort @class_mop_package_attributes ], [ sort keys %{$class_mop_package_meta->get_attribute_map} ], + [ sort @class_mop_package_attributes ], '... got the right list of attributes'); -foreach my $attribute_name (@class_mop_package_attributes) { +foreach my $attribute_name (sort @class_mop_package_attributes) { ok($class_mop_package_meta->has_attribute($attribute_name), '... Class::MOP::Package->has_attribute(' . $attribute_name . ')'); isa_ok($class_mop_package_meta->get_attribute($attribute_name), 'Class::MOP::Attribute'); } @@ -201,16 +199,16 @@ foreach my $attribute_name (@class_mop_package_attributes) { # check package is_deeply( - [ sort @class_mop_module_attributes ], [ sort $class_mop_module_meta->get_attribute_list ], + [ sort @class_mop_module_attributes ], '... got the right list of attributes'); is_deeply( - [ sort @class_mop_module_attributes ], [ sort keys %{$class_mop_module_meta->get_attribute_map} ], + [ sort @class_mop_module_attributes ], '... got the right list of attributes'); -foreach my $attribute_name (@class_mop_module_attributes) { +foreach my $attribute_name (sort @class_mop_module_attributes) { ok($class_mop_module_meta->has_attribute($attribute_name), '... Class::MOP::Module->has_attribute(' . $attribute_name . ')'); isa_ok($class_mop_module_meta->get_attribute($attribute_name), 'Class::MOP::Attribute'); } @@ -272,6 +270,21 @@ is($class_mop_class_meta->get_attribute('method_metaclass')->default, 'Class::MOP::Method', '... Class::MOP::Class method_metaclass\'s a default is Class::MOP:::Method'); +ok($class_mop_class_meta->get_attribute('wrapped_method_metaclass')->has_reader, '... Class::MOP::Class wrapped_method_metaclass has a reader'); +is_deeply($class_mop_class_meta->get_attribute('wrapped_method_metaclass')->reader, + { 'wrapped_method_metaclass' => \&Class::MOP::Class::wrapped_method_metaclass }, + '... Class::MOP::Class wrapped_method_metaclass\'s a reader is &wrapped_method_metaclass'); + +ok($class_mop_class_meta->get_attribute('wrapped_method_metaclass')->has_init_arg, '... Class::MOP::Class wrapped_method_metaclass has a init_arg'); +is($class_mop_class_meta->get_attribute('wrapped_method_metaclass')->init_arg, + 'wrapped_method_metaclass', + '... Class::MOP::Class wrapped_method_metaclass\'s init_arg is wrapped_method_metaclass'); + +ok($class_mop_class_meta->get_attribute('method_metaclass')->has_default, '... Class::MOP::Class method_metaclass has a default'); +is($class_mop_class_meta->get_attribute('method_metaclass')->default, + 'Class::MOP::Method', + '... Class::MOP::Class method_metaclass\'s a default is Class::MOP:::Method'); + # check the values of some of the methods is($class_mop_class_meta->name, 'Class::MOP::Class', '... Class::MOP::Class->name');