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