From: Shawn M Moore Date: Sun, 14 Dec 2008 21:01:50 +0000 (+0000) Subject: Make sure we can use traits => parameterized_role => { params } in an attribute X-Git-Tag: 0.05~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34a27044c774297c368154f3f318798cd9fb6728;p=gitmo%2FMooseX-Role-Parameterized.git Make sure we can use traits => parameterized_role => { params } in an attribute --- diff --git a/t/016-trait.t b/t/016-trait.t new file mode 100644 index 0000000..f7b68ea --- /dev/null +++ b/t/016-trait.t @@ -0,0 +1,52 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More skip_all => "Moose doesn't yet support traits with parameters"; +#use Test::More tests => 2; + +do { + package MyTrait::Label; + use MooseX::Role::Parameterized; + + parameter default => ( + is => 'rw', + isa => 'Str', + ); + + role { + my $p = shift; + + has label => ( + is => 'rw', + isa => 'Str', + default => $p->default, + ); + }; +}; + +do { + package MyClass::LabeledURL; + use Moose; + + has url => ( + traits => [ + 'MyTrait::Label' => { default => 'yay' }, + ], + is => 'rw', + isa => 'Str', + ); +}; + +do { + package MyClass::LabeledURL::Redux; + use Moose; + extends 'MyClass::LabeledURL'; + + has '+url' => ( + label => 'overridden', + ); +}; + +is(MyClass::LabeledURL->meta->get_attribute('url')->label, 'yay'); +is(MyClass::LabeledURL::Redux->meta->get_attribute('url')->label, 'overridden'); +