does_role no-meta'ing
[gitmo/Moose.git] / t / 020_attributes / 022_legal_options_for_inheritance.t
CommitLineData
aa08864c 1#!/usr/bin/perl
2
3use strict;
4use warnings;
7ff56534 5use Test::More tests => 2;
6
aa08864c 7
aa08864c 8
9{
10 package Bar::Meta::Attribute;
11 use Moose;
12
13 extends 'Moose::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 Moose;
26
27 has 'bar' => (
28 metaclass => 'Bar::Meta::Attribute',
29 my_legal_option => sub { 'Bar' }
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
42my $bar_attr = Bar::B->meta->get_attribute('bar');
43my ($legal_option) = grep {
44 $_ eq 'my_legal_option'
45} $bar_attr->legal_options_for_inheritance;
46is($legal_option, 'my_legal_option',
47 '... added my_legal_option as legal option for inheritance' );
48is($bar_attr->my_legal_option->(), 'Bar::B', '... overloaded my_legal_option');