-#!/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');
my @class_mop_module_methods = qw(
_new
- version authority identifier
+ version authority identifier create
);
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
# 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';
## 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';
## 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';
'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');
}
# 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');
}
# 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');
}
'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');