Move non-useful, Moose-specific methods into t/lib/Test/Mouse.pm
[gitmo/Mouse.git] / t / 014-build.t
index 0950acc..0d95047 100644 (file)
@@ -1,22 +1,21 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 12;
+use Test::More tests => 3;
 
-my ($class_build, $child_build) = (0, 0);
-my ($class_buildall, $child_buildall) = (0, 0);
+my @called;
 
 do {
     package Class;
     use Mouse;
 
     sub BUILD {
-        ++$class_build;
+        push @called, 'Class::BUILD';
     }
 
     sub BUILDALL {
         my $self = shift;
-        ++$class_buildall;
+        push @called, 'Class::BUILDALL';
         $self->SUPER::BUILDALL(@_);
     }
 
@@ -25,37 +24,22 @@ do {
     extends 'Class';
 
     sub BUILD {
-        ++$child_build;
+        push @called, 'Child::BUILD';
     }
 
     sub BUILDALL {
         my $self = shift;
-        ++$child_buildall;
+        push @called, 'Child::BUILDALL';
         $self->SUPER::BUILDALL(@_);
     }
-
-
 };
 
-is($class_build, 0, "no calls to Class->BUILD");
-is($child_build, 0, "no calls to Child->BUILD");
-
-is($class_buildall, 0, "no calls to Class->BUILDALL");
-is($child_buildall, 0, "no calls to Child->BUILDALL");
+is_deeply([splice @called], [], "no BUILD calls yet");
 
 my $object = Class->new;
 
-is($class_build, 1, "Class->new calls Class->BUILD");
-is($child_build, 0, "Class->new does not call Child->BUILD");
-
-is($class_buildall, 1, "Class->new calls Class->BUILDALL");
-is($child_buildall, 0, "no calls to Child->BUILDALL");
+is_deeply([splice @called], ["Class::BUILDALL", "Class::BUILD"]);
 
 my $child = Child->new;
 
-is($child_build, 1, "Child->new calls Child->BUILD");
-is($class_build, 2, "Child->new also calls Class->BUILD");
-
-is($child_buildall, 1, "Child->new calls Child->BUILDALL");
-is($class_buildall, 2, "Child->BUILDALL calls Class->BUILDALL (but not Child->new)");
-
+is_deeply([splice @called], ["Child::BUILDALL", "Class::BUILDALL", "Class::BUILD", "Child::BUILD"]);