Commit | Line | Data |
47e5060c |
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 | } |
6e77b8df |
24 | { |
25 | package MooseChild2; |
26 | use Moose; |
27 | extends 'MooParent'; |
28 | |
29 | has '+foo' => ( |
30 | default => 'MooseChild2', |
31 | ); |
32 | __PACKAGE__->meta->make_immutable |
33 | } |
47e5060c |
34 | |
35 | is( |
36 | MooseChild->new->foo, |
37 | 'MooseChild', |
38 | 'default value in Moose child' |
39 | ); |
40 | |
6e77b8df |
41 | is( |
42 | MooseChild2->new->foo, |
43 | 'MooseChild2', |
44 | 'default value in Moose child' |
45 | ); |
46 | |
47e5060c |
47 | done_testing; |
48 | |