Conflict on File::ChangeNotify for coerce changes
[gitmo/Moose.git] / t / 020_attributes / 022_legal_options_for_inheritance.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use Test::More;
6
7
8 {
9     package Bar::Meta::Attribute;
10     use Moose;
11
12     extends 'Moose::Meta::Attribute';
13
14     has 'my_legal_option' => (
15       isa => 'CodeRef',
16       is => 'rw',
17     );
18
19     around legal_options_for_inheritance => sub {
20       return (shift->(@_), qw/my_legal_option/);
21     };
22
23     package Bar;
24     use Moose;
25
26     has 'bar' => (
27       metaclass       => 'Bar::Meta::Attribute',
28       my_legal_option => sub { 'Bar' },
29       is => 'bare',
30     );
31
32     package Bar::B;
33     use Moose;
34
35     extends 'Bar';
36
37     has '+bar' => (
38       my_legal_option => sub { 'Bar::B' }
39     );
40 }
41
42 my $bar_attr = Bar::B->meta->get_attribute('bar');
43 my ($legal_option) = grep {
44   $_ eq 'my_legal_option'
45 } $bar_attr->legal_options_for_inheritance;
46 is($legal_option, 'my_legal_option',
47   '... added my_legal_option as legal option for inheritance' );
48 is($bar_attr->my_legal_option->(), 'Bar::B', '... overloaded my_legal_option');
49
50 done_testing;