s/make_immutable/metaclass->make_immutable/
[gitmo/Moose.git] / t / 030_roles / 017_extending_role_attrs.t
CommitLineData
8d62bf6d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 4;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose');
11}
12
13=pod
14
15This basically just makes sure that using +name
16on role attributes works right. It is pretty simple
17test really, but I wanted to have one since we are
18officially 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
42my $foo = Foo->new;
43isa_ok($foo, 'Foo');
44
45is($foo->bar, 100, '... got the extended attribute');
46