Fix many
[gitmo/Mouse.git] / t / 050_metaclasses / 020_metaclass_parameterized_traits.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 use Test::More;
6
7 BEGIN{
8     if($] < 5.008){
9         plan skip_all => "segv happens on 5.6.2";
10     }
11 }
12
13 use Test::More tests => 5;
14
15 {
16     package My::Trait;
17     use Mouse::Role;
18
19     sub reversed_name {
20         my $self = shift;
21         scalar reverse $self->name;
22     }
23 }
24
25 {
26     package My::Class;
27     use Mouse -traits => [
28         'My::Trait' => {
29             -alias => {
30                 reversed_name => 'enam',
31             },
32         },
33     ];
34 }
35
36 {
37     package My::Other::Class;
38     use Mouse -traits => [
39         'My::Trait' => {
40             -alias => {
41                 reversed_name => 'reversed',
42             },
43             -excludes => 'reversed_name',
44         },
45     ];
46 }
47
48 my $meta = My::Class->meta;
49 is($meta->enam, 'ssalC::yM', 'parameterized trait applied');
50 ok(!$meta->can('reversed'), "the method was not installed under the other class' alias");
51
52 my $other_meta = My::Other::Class->meta;
53 is($other_meta->reversed, 'ssalC::rehtO::yM', 'parameterized trait applied');
54 ok(!$other_meta->can('enam'), "the method was not installed under the other class' alias");
55 ok(!$other_meta->can('reversed_name'), "the method was not installed under the original name when that was excluded");
56