Commit | Line | Data |
04c8370f |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More tests => 12; |
5 | use Test::Exception; |
6 | use Test::NoWarnings; |
7 | |
8 | { |
9 | package Parent; |
10 | use Moose; |
11 | has attr => ( is => 'rw', isa => 'Str' ); |
12 | } |
13 | |
14 | { |
15 | package Child; |
16 | use Moose; |
17 | extends 'Parent'; |
18 | |
19 | has '+attr' => ( lazy_build => 1 ); |
20 | sub _build_attr |
21 | { |
22 | return 'value'; |
23 | } |
24 | } |
25 | |
26 | package main; |
27 | |
28 | my $parent = Parent->new(); |
29 | my $child = Child->new(); |
30 | |
31 | ok(!$parent->meta->get_attribute('attr')->is_lazy_build, |
32 | 'attribute in parent does not have lazy_build trait'); |
33 | ok(!$parent->meta->get_attribute('attr')->is_lazy, |
34 | 'attribute in parent does not have lazy trait'); |
35 | ok(!$parent->meta->get_attribute('attr')->has_builder, |
36 | 'attribute in parent does not have a builder method'); |
37 | ok(!$parent->meta->get_attribute('attr')->has_clearer, |
38 | 'attribute in parent does not have a clearer method'); |
39 | ok(!$parent->meta->get_attribute('attr')->has_predicate, |
40 | 'attribute in parent does not have a predicate method'); |
41 | |
42 | ok($child->meta->get_attribute('attr')->is_lazy_build, |
43 | 'attribute in child has the lazy_build trait'); |
44 | ok($child->meta->get_attribute('attr')->is_lazy, |
45 | 'attribute in child has the lazy trait'); |
46 | ok($child->meta->get_attribute('attr')->has_builder, |
47 | 'attribute in child has a builder method'); |
48 | ok($child->meta->get_attribute('attr')->has_clearer, |
49 | 'attribute in child has a clearer method'); |
50 | ok($child->meta->get_attribute('attr')->has_predicate, |
51 | 'attribute in child has a predicate method'); |
52 | |
53 | is($child->attr, 'value', 'attribute defined as lazy_build in child is properly built'); |