6 use Test::More tests => 8;
8 use Scalar::Util 'blessed';
12 This test it kind of odd, it tests
13 to see if make_immutable will DWIM
14 when pressented with a class that
15 inherits from a non-Moose base class.
17 Since immutable only affects the local
18 class, and if it doesnt find a constructor
19 it will always create one, it won't
20 discover this issue, and it will ignore
21 the inherited constructor.
23 This is not really the desired way, but
24 detecting this opens a big can of worms
25 which we are not going to deal with just
26 yet (eventually yes, but most likely it
27 will be when we have MooseX::Compile
28 available and working).
30 In the meantime, just know that when you
31 call make_immutable on a class which
32 inherits from a non-Moose class, you
33 should add (inline_constructor => 0).
45 grandparent => 'gramma',
49 bless \%args => $class;
58 extends 'Grandparent';
80 __PACKAGE__->meta->make_immutable;
83 is(blessed(Grandparent->new), "Grandparent", "got a Grandparent object out of Grandparent->new");
84 is(blessed(Parent->new), "Parent", "got a Parent object out of Parent->new");
85 is(blessed(Child->new), "Child", "got a Child object out of Child->new");
87 is(Child->new->grandparent, 1, "Child responds to grandparent");
88 is(Child->new->parent, 1, "Child responds to parent");
89 is(Child->new->child, 1, "Child responds to child");
91 is(Child->new->{grandparent}, undef, "didnt create a value, cause immutable overode the constructor");
92 is(Child->new->{parent}, undef, "didnt create a value, cause immutable overode the constructor");