(exists $SIGIL_MAP{$sigil})
|| confess "I do not recognize that sigil '$sigil'";
- no strict 'refs';
- if ($SIGIL_MAP{$sigil} eq 'SCALAR') {
- undef ${$self->name . '::' . $name};
- }
- elsif ($SIGIL_MAP{$sigil} eq 'ARRAY') {
- undef @{$self->name . '::' . $name};
- }
- elsif ($SIGIL_MAP{$sigil} eq 'HASH') {
- undef %{$self->name . '::' . $name};
- }
- elsif ($SIGIL_MAP{$sigil} eq 'CODE') {
- undef &{$self->name . '::' . $name};
- }
- else {
- confess "This should never ever ever happen";
- }
+ no strict 'refs';
+ if ($SIGIL_MAP{$sigil} eq 'SCALAR') {
+ undef ${$self->name . '::' . $name};
+ }
+ elsif ($SIGIL_MAP{$sigil} eq 'ARRAY') {
+ undef @{$self->name . '::' . $name};
+ }
+ elsif ($SIGIL_MAP{$sigil} eq 'HASH') {
+ undef %{$self->name . '::' . $name};
+ }
+ elsif ($SIGIL_MAP{$sigil} eq 'CODE') {
+ undef &{$self->name . '::' . $name};
+ }
+ else {
+ confess "This should never ever ever happen";
+ }
}
use strict;
use warnings;
-use Test::More tests => 164;
+use Test::More tests => 169;
use Test::Exception;
BEGIN {
);
my @class_mop_module_methods = qw(
+ meta
+
+ version
);
my @class_mop_class_methods = qw(
construct_instance construct_class_instance clone_instance
check_metaclass_compatability
- version
-
attribute_metaclass method_metaclass
superclasses class_precedence_list
is_mutable is_immutable make_immutable
DESTROY
- );
+);
# check the class ...
}
}
+## 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');
+
+foreach my $method_name (@class_mop_module_methods) {
+ ok($class_mop_module_meta->has_method($method_name), '... Class::MOP::Module->has_method(' . $method_name . ')');
+ {
+ no strict 'refs';
+ is($class_mop_module_meta->get_method($method_name),
+ \&{'Class::MOP::Module::' . $method_name},
+ '... Class::MOP::Module->get_method(' . $method_name . ') == &Class::MOP::Module::' . $method_name);
+ }
+}
+
+
# check for imported functions which are not methods
foreach my $non_method_name (qw(
isa_ok($class_mop_class_meta->get_attribute($attribute_name), 'Class::MOP::Attribute');
}
-# check package
+# check module
is_deeply(
[ sort @class_mop_package_attributes ],
isa_ok($class_mop_package_meta->get_attribute($attribute_name), 'Class::MOP::Attribute');
}
+# check package
+
+is_deeply(
+ [ sort @class_mop_module_attributes ],
+ [ sort $class_mop_module_meta->get_attribute_list ],
+ '... got the right list of attributes');
+
+is_deeply(
+ [ sort @class_mop_module_attributes ],
+ [ sort keys %{$class_mop_module_meta->get_attribute_map} ],
+ '... got the right list of attributes');
+
+foreach my $attribute_name (@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');
+}
+
## check the attributes themselves
# ... package