Remove our (now broken) dzil GatherDir subclass
[gitmo/Moose.git] / t / attributes / inherit_lazy_build.t
CommitLineData
04c8370f 1use strict;
2use warnings;
3
4acaa12e 4use Test::More;
04c8370f 5
6{
4acaa12e 7
04c8370f 8 package Parent;
9 use Moose;
10 has attr => ( is => 'rw', isa => 'Str' );
11}
12
13{
14 package Child;
15 use Moose;
16 extends 'Parent';
17
18 has '+attr' => ( lazy_build => 1 );
4acaa12e 19
20 sub _build_attr {
04c8370f 21 return 'value';
22 }
23}
24
04c8370f 25my $parent = Parent->new();
4acaa12e 26my $child = Child->new();
27
28ok(
29 !$parent->meta->get_attribute('attr')->is_lazy_build,
30 'attribute in parent does not have lazy_build trait'
31);
32ok(
33 !$parent->meta->get_attribute('attr')->is_lazy,
34 'attribute in parent does not have lazy trait'
35);
36ok(
37 !$parent->meta->get_attribute('attr')->has_builder,
38 'attribute in parent does not have a builder method'
39);
40ok(
41 !$parent->meta->get_attribute('attr')->has_clearer,
42 'attribute in parent does not have a clearer method'
43);
44ok(
45 !$parent->meta->get_attribute('attr')->has_predicate,
46 'attribute in parent does not have a predicate method'
47);
48
49ok(
50 $child->meta->get_attribute('attr')->is_lazy_build,
51 'attribute in child has the lazy_build trait'
52);
53ok(
54 $child->meta->get_attribute('attr')->is_lazy,
55 'attribute in child has the lazy trait'
56);
57ok(
58 $child->meta->get_attribute('attr')->has_builder,
59 'attribute in child has a builder method'
60);
61ok(
62 $child->meta->get_attribute('attr')->has_clearer,
63 'attribute in child has a clearer method'
64);
65ok(
66 $child->meta->get_attribute('attr')->has_predicate,
67 'attribute in child has a predicate method'
68);
69
70is(
71 $child->attr, 'value',
72 'attribute defined as lazy_build in child is properly built'
73);
74
75done_testing;