Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
224bfdd8 |
4 | use Test::More tests => 5; |
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 | |
224bfdd8 |
16 | # sub BUILDALL { |
17 | # my $self = shift; |
18 | # push @called, 'Class::BUILDALL'; |
19 | # $self->SUPER::BUILDALL(@_); |
20 | # } |
c3398f5b |
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 | |
224bfdd8 |
30 | # sub BUILDALL { |
31 | # my $self = shift; |
32 | # push @called, 'Child::BUILDALL'; |
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 | |
224bfdd8 |
41 | is_deeply([splice @called], ["Class::BUILD"]); |
c3398f5b |
42 | |
43 | my $child = Child->new; |
44 | |
224bfdd8 |
45 | is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"]); |
46 | |
47 | Class->meta->make_immutable; |
48 | Child->meta->make_immutable; |
49 | |
50 | $object = Class->new; |
51 | |
52 | is_deeply([splice @called], ["Class::BUILD"], 'after make_immutable'); |
53 | |
54 | $child = Child->new; |
55 | |
56 | is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"], 'after make_immutable'); |
57 | |