X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2Ffailing%2F024_attribute_traits_parameterized.t;fp=t%2F020_attributes%2Ffailing%2F024_attribute_traits_parameterized.t;h=57a3d0509fc1a13a5087c28c5f22225aa566572e;hb=4060c871da12ba3c5e88986ed121a8254f906bd6;hp=0000000000000000000000000000000000000000;hpb=95ecd6f132112c6763cdaf2e6bc72c39e9ab76b5;p=gitmo%2FMouse.git diff --git a/t/020_attributes/failing/024_attribute_traits_parameterized.t b/t/020_attributes/failing/024_attribute_traits_parameterized.t new file mode 100644 index 0000000..57a3d05 --- /dev/null +++ b/t/020_attributes/failing/024_attribute_traits_parameterized.t @@ -0,0 +1,57 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 5; + +{ + package My::Attribute::Trait; + use Mouse::Role; + + sub reversed_name { + my $self = shift; + scalar reverse $self->name; + } +} + +{ + package My::Class; + use Mouse; + + has foo => ( + traits => [ + 'My::Attribute::Trait' => { + -alias => { + reversed_name => 'eman', + }, + }, + ], + is => 'bare', + ); +} + +{ + package My::Other::Class; + use Mouse; + + has foo => ( + traits => [ + 'My::Attribute::Trait' => { + -alias => { + reversed_name => 'reversed', + }, + -excludes => 'reversed_name', + }, + ], + is => 'bare', + ); +} + +my $attr = My::Class->meta->get_attribute('foo'); +is($attr->eman, 'oof', 'the aliased method is in the attribute'); +ok(!$attr->can('reversed'), "the method was not installed under the other class' alias"); + +my $other_attr = My::Other::Class->meta->get_attribute('foo'); +is($other_attr->reversed, 'oof', 'the aliased method is in the attribute'); +ok(!$other_attr->can('enam'), "the method was not installed under the other class' alias"); +ok(!$other_attr->can('reversed_name'), "the method was not installed under the original name when that was excluded"); +