Update changes for release
[gitmo/Class-MOP.git] / t / 010_self_introspection.t
index 00006be..5751cbe 100644 (file)
@@ -1,17 +1,13 @@
-#!/usr/bin/perl
-
 use strict;
 use warnings;
 
-use Test::More tests => 234;
+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(
@@ -63,18 +59,19 @@ my @class_mop_class_methods = qw(
     new_object clone_object
     construct_instance construct_class_instance clone_instance
     rebless_instance
+    check_metaclass_compatibility
     check_metaclass_compatability
 
     add_meta_instance_dependencies remove_meta_instance_depdendencies update_meta_instance_dependencies
     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
@@ -90,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';
@@ -104,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';
@@ -118,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';
@@ -160,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');
 }
@@ -183,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');
 }
@@ -200,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');
 }
@@ -271,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');