Add test in Class:MOP for ->identifier() and immutable not playing nice. Fix by makin...
Tomas Doran [Fri, 16 May 2008 01:35:00 +0000 (01:35 +0000)]
lib/Class/MOP/Class.pm
lib/Class/MOP/Immutable.pm
t/070_immutable_metaclass.t

index aa0602e..9977409 100644 (file)
@@ -907,7 +907,6 @@ sub create_immutable_transformer {
            remove_method
            add_attribute
            remove_attribute
-           add_package_symbol
            remove_package_symbol
        /],
        memoize     => {
@@ -916,7 +915,14 @@ sub create_immutable_transformer {
            compute_all_applicable_attributes => 'ARRAY',
            get_meta_instance                 => 'SCALAR',
            get_method_map                    => 'SCALAR',
-       }
+       },
+       around => { 
+           add_package_symbol => sub {
+               my $original = shift;
+               confess "NO ADD SYMBOLS FOR YOU" unless caller eq 'get_package_symbol'; 
+               $original->(@_);
+           },
+       },
     });
     return $class;
 }
index 3cb1054..f4a84b0 100644 (file)
@@ -8,6 +8,7 @@ use Class::MOP::Method::Constructor;
 
 use Carp         'confess';
 use Scalar::Util 'blessed';
+use Sub::Name    'subname';
 
 our $VERSION   = '0.05';
 our $AUTHORITY = 'cpan:STEVAN';
@@ -233,6 +234,13 @@ sub create_methods_for_immutable_metaclass {
             $methods{$method_name} = sub { $_[0]->{'___' . $method_name} };
         }
     }
+    
+    my $around_methods = $self->options->{around};
+    foreach my $method_name (keys %{$around_methods}) {
+        my $method = $self->metaclass->meta->find_method_by_name($method_name);
+        $method = Class::MOP::Method::Wrapped->wrap($method);
+        $method->add_around_modifier(subname ':around' => $around_methods->{$method_name});
+    }
 
     $methods{get_mutable_metaclass_name} = sub { (shift)->{'___original_class'} };
 
index c88d914..ffc8b76 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 83;
+use Test::More tests => 84;
 use Test::Exception;
 
 BEGIN {
@@ -96,6 +96,7 @@ BEGIN {
 
     dies_ok { $meta->add_package_symbol()    } '... exception thrown as expected';
     dies_ok { $meta->remove_package_symbol() } '... exception thrown as expected';
+    lives_ok{ $meta->identifier()            } '... no exception for get_package_symbol special case';
 
     my @supers;
     lives_ok {