Changelogging
[gitmo/Mouse.git] / t / 001_mouse / 014-build.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
224bfdd8 4use Test::More tests => 5;
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
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 37is_deeply([splice @called], [], "no BUILD calls yet");
c3398f5b 38
39my $object = Class->new;
40
224bfdd8 41is_deeply([splice @called], ["Class::BUILD"]);
c3398f5b 42
43my $child = Child->new;
44
224bfdd8 45is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"]);
46
47Class->meta->make_immutable;
48Child->meta->make_immutable;
49
50$object = Class->new;
51
52is_deeply([splice @called], ["Class::BUILD"], 'after make_immutable');
53
54$child = Child->new;
55
56is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"], 'after make_immutable');
57