fb3c31e83be0e8dc4c4440a6fb05e0d03905b3a7
[gitmo/Moo.git] / xt / moose-override-attribute-with-plus-syntax.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use Test::Fatal;
5
6 {
7     package MooParent;
8     use Moo;
9
10     has foo => (
11         is => 'ro',
12         default => sub { 'MooParent' },
13     );
14 }
15 {
16     package MooseChild;
17     use Moose;
18     extends 'MooParent';
19
20     has '+foo' => (
21         default => 'MooseChild',
22     );
23 }
24 {
25     package MooseChild2;
26     use Moose;
27     extends 'MooParent';
28
29     has '+foo' => (
30         default => 'MooseChild2',
31     );
32     __PACKAGE__->meta->make_immutable
33 }
34
35 is(
36     MooseChild->new->foo,
37     'MooseChild',
38     'default value in Moose child'
39 );
40
41 is(
42     MooseChild2->new->foo,
43     'MooseChild2',
44     'default value in Moose child'
45 );
46
47 done_testing;
48