Regenerate test files
[gitmo/Mouse.git] / t / 020_attributes / 024_attribute_traits_parameterized.t
CommitLineData
4060c871 1#!/usr/bin/env perl
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
4060c871 5use strict;
6use warnings;
fde8e43f 7use 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
52my $attr = My::Class->meta->get_attribute('foo');
53is($attr->eman, 'oof', 'the aliased method is in the attribute');
54ok(!$attr->can('reversed'), "the method was not installed under the other class' alias");
55
56my $other_attr = My::Other::Class->meta->get_attribute('foo');
57is($other_attr->reversed, 'oof', 'the aliased method is in the attribute');
58ok(!$other_attr->can('enam'), "the method was not installed under the other class' alias");
59ok(!$other_attr->can('reversed_name'), "the method was not installed under the original name when that was excluded");
60
fde8e43f 61done_testing;