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