Ensure that we're not blowing away an inherited constructor
[gitmo/Mouse.git] / t / 014-build.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
9acd019a 4use Test::More tests => 3;
c3398f5b 5
9acd019a 6my @called;
c3398f5b 7
8do {
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 37is_deeply([splice @called], [], "no BUILD calls yet");
c3398f5b 38
39my $object = Class->new;
40
9acd019a 41is_deeply([splice @called], ["Class::BUILDALL", "Class::BUILD"]);
c3398f5b 42
43my $child = Child->new;
44
9acd019a 45is_deeply([splice @called], ["Child::BUILDALL", "Class::BUILDALL", "Class::BUILD", "Child::BUILD"]);