From: Shawn M Moore Date: Thu, 19 Jun 2008 01:58:15 +0000 (+0000) Subject: Ensure that the local class wins over a role, and that the role over a parent class X-Git-Tag: 0.19~280 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f650b4b277efdfd6ef28305722959d6f1670a99c;p=gitmo%2FMouse.git Ensure that the local class wins over a role, and that the role over a parent class --- diff --git a/t/402-attribute-application.t b/t/402-attribute-application.t index d05f818..fbb400d 100644 --- a/t/402-attribute-application.t +++ b/t/402-attribute-application.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 11; use Test::Exception; do { @@ -48,3 +48,37 @@ lives_ok { is(Class2->meta->get_attribute('attr')->default, 'Role'); +lives_ok { + package Class3; + use Mouse; + + with 'Role'; + + has attr => ( + default => 'Class3', + ); +}; + +is(Class3->meta->get_attribute('attr')->default, 'Class3'); + +lives_ok { + package Class::Parent; + use Mouse; + + has attr => ( + default => 'Class::Parent', + ); +}; + +is(Class::Parent->meta->get_attribute('attr')->default, 'Class::Parent', 'local class wins over the role'); + +lives_ok { + package Class::Child; + use Mouse; + + extends 'Class::Parent'; + + with 'Role'; +}; + +is(Class::Child->meta->get_attribute('attr')->default, 'Role', 'role wins over the parent method');