has +name from role officially supported
[gitmo/Moose.git] / t / 030_roles / 017_extending_role_attrs.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
7 use Test::Exception;
8
9 BEGIN {
10     use_ok('Moose');
11 }
12
13 =pod
14
15 This basically just makes sure that using +name 
16 on role attributes works right. It is pretty simple
17 test really, but I wanted to have one since we are 
18 officially supporting the feature now.
19
20 =cut
21
22 {
23     package Foo::Role;
24     use Moose::Role;
25     
26     has 'bar' => (
27         is      => 'rw',
28         isa     => 'Int',   
29         default => sub { 10 },
30     );
31     
32     package Foo;
33     use Moose;
34     
35     with 'Foo::Role';
36     
37     ::lives_ok {
38         has '+bar' => (default => sub { 100 });
39     } '... extended the attribute successfully';  
40 }
41
42 my $foo = Foo->new;
43 isa_ok($foo, 'Foo');
44
45 is($foo->bar, 100, '... got the extended attribute');
46