Optimize Method::Delegation
[gitmo/Mouse.git] / t / 001_mouse / 014-build.t
index 0d95047..b1e3293 100644 (file)
@@ -1,7 +1,8 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 3;
+use Test::More tests => 9;
+use Test::Mouse;
 
 my @called;
 
@@ -13,11 +14,11 @@ do {
         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;
@@ -27,19 +28,28 @@ do {
         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"]);