summaryrefslogtreecommitdiffstats
path: root/t/25-constructor-method-calls.t
blob: 7187bb831bf367a251fd24a4022715bc207ac93a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Moose;

my ($foo, $foosub);
{
    package Foo;

    sub new {
        my $class = shift;
        my $obj = bless {}, $class;
        $obj->init;
        $obj;
    }

    sub init {
        $foo++
    }
}

{
    package Foo::Sub;
    use base 'Foo';

    sub init {
        $foosub++;
        shift->SUPER::init;
    }
}

{
    package Foo::Sub::Sub;
    use Moose;
    use MooseX::NonMoose;
    extends 'Foo::Sub';
}

with_immutable {
    ($foo, $foosub) = (0, 0);
    Foo::Sub::Sub->new;
    is($foo, 1, "Foo::init called");
    is($foosub, 1, "Foo::Sub::init called");
} 'Foo::Sub::Sub';

done_testing;