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