Add some tests
[gitmo/Mouse.git] / lib / Mouse / Meta / Role.pm
index 4b5c26f..aff399f 100644 (file)
@@ -9,7 +9,7 @@ use base qw(Mouse::Meta::Module);
 
 sub method_metaclass(){ 'Mouse::Meta::Role::Method' } # required for get_method()
 
-sub _new {
+sub _construct_meta {
     my $class = shift;
 
     my %args  = @_;
@@ -22,7 +22,7 @@ sub _new {
 #    return Mouse::Meta::Class->initialize($class)->new_object(%args)
 #        if $class ne __PACKAGE__;
 
-    return bless \%args, $class;
+    return bless \%args, ref($class) || $class;
 }
 
 sub create_anon_role{
@@ -288,7 +288,7 @@ sub combine_apply {
             my $attr = $role->get_attribute($attr_name);
             my $c    = $attr_provided{$attr_name};
             if($c && $c != $attr){
-                $class->throw_error("We have encountered an attribute conflict with '$attr_name' "\r
+                $class->throw_error("We have encountered an attribute conflict with '$attr_name' "
                                    . "during composition. This is fatal error and cannot be disambiguated.")
             }
             else{
@@ -301,8 +301,8 @@ sub combine_apply {
             my $override = $role->get_override_method_modifier($method_name);
             my $c        = $override_provided{$method_name};
             if($c && $c != $override){
-                $class->throw_error( "We have encountered an 'override' method conflict with '$method_name' during "\r
-                                   . "composition (Two 'override' methods of the same name encountered). "\r
+                $class->throw_error( "We have encountered an 'override' method conflict with '$method_name' during "
+                                   . "composition (Two 'override' methods of the same name encountered). "
                                    . "This is fatal error.")
             }
             else{
@@ -382,7 +382,7 @@ sub add_override_method_modifier{
     if($self->has_method($method_name)){
         # This error happens in the override keyword or during role composition,
         # so I added a message, "A local method of ...", only for compatibility (gfx)
-        $self->throw_error("Cannot add an override of method '$method_name' "\r
+        $self->throw_error("Cannot add an override of method '$method_name' "
                    . "because there is a local version of '$method_name'"
                    . "(A local method of the same name as been found)");
     }
@@ -390,14 +390,14 @@ sub add_override_method_modifier{
     $self->{override_method_modifiers}->{$method_name} = $method;
 }
 
-sub has_override_method_modifier {\r
-    my ($self, $method_name) = @_;\r
-    return exists $self->{override_method_modifiers}->{$method_name};\r
-}\r
-\r
-sub get_override_method_modifier {\r
-    my ($self, $method_name) = @_;\r
-    return $self->{override_method_modifiers}->{$method_name};\r
+sub has_override_method_modifier {
+    my ($self, $method_name) = @_;
+    return exists $self->{override_method_modifiers}->{$method_name};
+}
+
+sub get_override_method_modifier {
+    my ($self, $method_name) = @_;
+    return $self->{override_method_modifiers}->{$method_name};
 }
 
 sub get_method_modifier_list {