Tweaks for 5.6.2
[gitmo/Mouse.git] / t / 001_mouse / 014-build.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
289e5430 4use Test::More tests => 9;
5use Test::Mouse;
c3398f5b 6
9acd019a 7my @called;
c3398f5b 8
9do {
10 package Class;
043a69fb 11 use Mouse;
c3398f5b 12
13 sub BUILD {
9acd019a 14 push @called, 'Class::BUILD';
c3398f5b 15 }
16
224bfdd8 17# sub BUILDALL {
18# my $self = shift;
19# push @called, 'Class::BUILDALL';
20# $self->SUPER::BUILDALL(@_);
21# }
c3398f5b 22
23 package Child;
043a69fb 24 use Mouse;
c3398f5b 25 extends 'Class';
26
27 sub BUILD {
9acd019a 28 push @called, 'Child::BUILD';
c3398f5b 29 }
30
224bfdd8 31# sub BUILDALL {
32# my $self = shift;
33# push @called, 'Child::BUILDALL';
34# $self->SUPER::BUILDALL(@_);
35# }
c3398f5b 36};
37
9acd019a 38is_deeply([splice @called], [], "no BUILD calls yet");
c3398f5b 39
029463f4 40with_immutable sub {
289e5430 41 my $object = Class->new;
c3398f5b 42
289e5430 43 ok defined($object), $object->meta->is_immutable() ? 'mutable' : 'immutable';
c3398f5b 44
289e5430 45 is_deeply([splice @called], ["Class::BUILD"]);
c3398f5b 46
289e5430 47 my $child = Child->new;
224bfdd8 48
289e5430 49 is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"]);
224bfdd8 50
289e5430 51 $child->BUILDALL({});
224bfdd8 52
289e5430 53 is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"], 'BUILDALL');
029463f4 54}, qw(Class Child);
224bfdd8 55