Commit | Line | Data |
4060c871 |
1 | #!/usr/bin/env perl |
1f5ce14a |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
4060c871 |
5 | use strict; |
6 | use warnings; |
1f5ce14a |
7 | use Test::More; |
4060c871 |
8 | |
9 | { |
10 | package My::Attribute::Trait; |
11 | use Mouse::Role; |
12 | |
13 | sub reversed_name { |
14 | my $self = shift; |
15 | scalar reverse $self->name; |
16 | } |
17 | } |
18 | |
19 | { |
20 | package My::Class; |
21 | use Mouse; |
22 | |
23 | has foo => ( |
24 | traits => [ |
25 | 'My::Attribute::Trait' => { |
26 | -alias => { |
27 | reversed_name => 'eman', |
28 | }, |
29 | }, |
30 | ], |
31 | is => 'bare', |
32 | ); |
33 | } |
34 | |
35 | { |
36 | package My::Other::Class; |
37 | use Mouse; |
38 | |
39 | has foo => ( |
40 | traits => [ |
41 | 'My::Attribute::Trait' => { |
42 | -alias => { |
43 | reversed_name => 'reversed', |
44 | }, |
45 | -excludes => 'reversed_name', |
46 | }, |
47 | ], |
48 | is => 'bare', |
49 | ); |
50 | } |
51 | |
52 | my $attr = My::Class->meta->get_attribute('foo'); |
53 | is($attr->eman, 'oof', 'the aliased method is in the attribute'); |
54 | ok(!$attr->can('reversed'), "the method was not installed under the other class' alias"); |
55 | |
56 | my $other_attr = My::Other::Class->meta->get_attribute('foo'); |
57 | is($other_attr->reversed, 'oof', 'the aliased method is in the attribute'); |
58 | ok(!$other_attr->can('enam'), "the method was not installed under the other class' alias"); |
59 | ok(!$other_attr->can('reversed_name'), "the method was not installed under the original name when that was excluded"); |
60 | |
1f5ce14a |
61 | done_testing; |