Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
9acd019a |
4 | use Test::More tests => 3; |
c3398f5b |
5 | |
9acd019a |
6 | my @called; |
c3398f5b |
7 | |
8 | do { |
9 | package Class; |
043a69fb |
10 | use Mouse; |
c3398f5b |
11 | |
12 | sub BUILD { |
9acd019a |
13 | push @called, 'Class::BUILD'; |
c3398f5b |
14 | } |
15 | |
16 | sub BUILDALL { |
17 | my $self = shift; |
9acd019a |
18 | push @called, 'Class::BUILDALL'; |
c3398f5b |
19 | $self->SUPER::BUILDALL(@_); |
20 | } |
21 | |
22 | package Child; |
043a69fb |
23 | use Mouse; |
c3398f5b |
24 | extends 'Class'; |
25 | |
26 | sub BUILD { |
9acd019a |
27 | push @called, 'Child::BUILD'; |
c3398f5b |
28 | } |
29 | |
30 | sub BUILDALL { |
31 | my $self = shift; |
9acd019a |
32 | push @called, 'Child::BUILDALL'; |
c3398f5b |
33 | $self->SUPER::BUILDALL(@_); |
34 | } |
c3398f5b |
35 | }; |
36 | |
9acd019a |
37 | is_deeply([splice @called], [], "no BUILD calls yet"); |
c3398f5b |
38 | |
39 | my $object = Class->new; |
40 | |
9acd019a |
41 | is_deeply([splice @called], ["Class::BUILDALL", "Class::BUILD"]); |
c3398f5b |
42 | |
43 | my $child = Child->new; |
44 | |
9acd019a |
45 | is_deeply([splice @called], ["Child::BUILDALL", "Class::BUILDALL", "Class::BUILD", "Child::BUILD"]); |