Commit | Line | Data |
34a27044 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More skip_all => "Moose doesn't yet support traits with parameters"; |
5 | #use Test::More tests => 2; |
6 | |
7 | do { |
8 | package MyTrait::Label; |
9 | use MooseX::Role::Parameterized; |
10 | |
11 | parameter default => ( |
12 | is => 'rw', |
13 | isa => 'Str', |
14 | ); |
15 | |
16 | role { |
17 | my $p = shift; |
18 | |
19 | has label => ( |
20 | is => 'rw', |
21 | isa => 'Str', |
22 | default => $p->default, |
23 | ); |
24 | }; |
25 | }; |
26 | |
27 | do { |
28 | package MyClass::LabeledURL; |
29 | use Moose; |
30 | |
31 | has url => ( |
32 | traits => [ |
33 | 'MyTrait::Label' => { default => 'yay' }, |
34 | ], |
34a27044 |
35 | ); |
36 | }; |
37 | |
38 | do { |
39 | package MyClass::LabeledURL::Redux; |
40 | use Moose; |
34a27044 |
41 | |
9857cc15 |
42 | has 'url' => ( |
43 | traits => [ |
44 | 'MyTrait::Label' => { default => 'yay' }, |
45 | ], |
34a27044 |
46 | label => 'overridden', |
47 | ); |
48 | }; |
49 | |
50 | is(MyClass::LabeledURL->meta->get_attribute('url')->label, 'yay'); |
51 | is(MyClass::LabeledURL::Redux->meta->get_attribute('url')->label, 'overridden'); |
52 | |