#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 9;
+use Test::Mouse;
my @called;
push @called, 'Class::BUILD';
}
- sub BUILDALL {
- my $self = shift;
- push @called, 'Class::BUILDALL';
- $self->SUPER::BUILDALL(@_);
- }
+# sub BUILDALL {
+# my $self = shift;
+# push @called, 'Class::BUILDALL';
+# $self->SUPER::BUILDALL(@_);
+# }
package Child;
use Mouse;
push @called, 'Child::BUILD';
}
- sub BUILDALL {
- my $self = shift;
- push @called, 'Child::BUILDALL';
- $self->SUPER::BUILDALL(@_);
- }
+# sub BUILDALL {
+# my $self = shift;
+# push @called, 'Child::BUILDALL';
+# $self->SUPER::BUILDALL(@_);
+# }
};
is_deeply([splice @called], [], "no BUILD calls yet");
-my $object = Class->new;
+with_immutable sub {
+ my $object = Class->new;
+
+ ok defined($object), $object->meta->is_immutable() ? 'mutable' : 'immutable';
+
+ is_deeply([splice @called], ["Class::BUILD"]);
+
+ my $child = Child->new;
+
+ is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"]);
-is_deeply([splice @called], ["Class::BUILDALL", "Class::BUILD"]);
+ $child->BUILDALL({});
-my $child = Child->new;
+ is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"], 'BUILDALL');
+}, qw(Class Child);
-is_deeply([splice @called], ["Child::BUILDALL", "Class::BUILDALL", "Class::BUILD", "Child::BUILD"]);