Failing make_immutable test case. It seems that inherited "new" is just plain broken...
[gitmo/Moose.git] / t / 300_immutable / 006_immutable_nonmoose_subclass.t
CommitLineData
0aac92c5 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 10;
7use Test::Exception;
8use Scalar::Util 'blessed';
9
10BEGIN {
11 use_ok('Moose');
12 use_ok('Moose::Meta::Role');
13}
14
15{
16 package Grandparent;
17
18 sub new {
19 my $class = shift;
20 my %args = (
21 grandparent => 'gramma',
22 @_,
23 );
24
25 bless \%args => $class;
26 }
27
28 sub grandparent { 1 }
29}
30
31{
32 package Parent;
33 use Moose;
34 extends 'Grandparent';
35
36 around new => sub {
37 my $orig = shift;
38 my $class = shift;
39
40 $class->$orig(
41 parent => 'mama',
42 @_,
43 );
44 };
45
46 sub parent { 1 }
47}
48
49{
50 package Child;
51 use Moose;
52 extends 'Parent';
53
54 sub child { 1 }
55
56 make_immutable;
57}
58
59is(blessed(Grandparent->new), "Grandparent", "got a Grandparent object out of Grandparent->new");
60is(blessed(Parent->new), "Parent", "got a Parent object out of Parent->new");
61is(blessed(Child->new), "Child", "got a Child object out of Child->new");
62
63is(Child->new->grandparent, 1, "Child responds to grandparent");
64is(Child->new->parent, 1, "Child responds to parent");
65is(Child->new->child, 1, "Child responds to child");
66
67is(Child->new->{grandparent}, 'gramma', "Instance structure has attributes");
68is(Child->new->{parent}, 'mama', "Parent's 'around' is respected");
69