Commit | Line | Data |
41888e7d |
1 | #!/usr/bin/env perl |
6217087a |
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; |
41888e7d |
5 | use strict; |
6 | use warnings; |
6217087a |
7 | use Test::More; |
41888e7d |
8 | |
9 | { |
10 | package My::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 -traits => [ |
22 | 'My::Trait' => { |
23 | -alias => { |
24 | reversed_name => 'enam', |
25 | }, |
26 | }, |
27 | ]; |
28 | } |
29 | |
30 | { |
31 | package My::Other::Class; |
32 | use Mouse -traits => [ |
33 | 'My::Trait' => { |
34 | -alias => { |
35 | reversed_name => 'reversed', |
36 | }, |
37 | -excludes => 'reversed_name', |
38 | }, |
39 | ]; |
40 | } |
41 | |
42 | my $meta = My::Class->meta; |
43 | is($meta->enam, 'ssalC::yM', 'parameterized trait applied'); |
44 | ok(!$meta->can('reversed'), "the method was not installed under the other class' alias"); |
45 | |
46 | my $other_meta = My::Other::Class->meta; |
47 | is($other_meta->reversed, 'ssalC::rehtO::yM', 'parameterized trait applied'); |
48 | ok(!$other_meta->can('enam'), "the method was not installed under the other class' alias"); |
49 | ok(!$other_meta->can('reversed_name'), "the method was not installed under the original name when that was excluded"); |
50 | |
6217087a |
51 | done_testing; |