summaryrefslogtreecommitdiffstats
path: root/t/50-buggy-constructor-inlining.t
blob: 591fae0da72f85d4c5019306ff37c8517c3758ac (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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 6;

my ($Foo, $Bar, $Baz) = (0, 0, 0);
{
    package Foo;
    sub new { $Foo++; bless {}, shift }
}

{
    package Bar;
    use Moose;
    use MooseX::NonMoose;
    extends 'Foo';
    sub BUILD { $Bar++ }
    __PACKAGE__->meta->make_immutable;
}

{
    package Baz;
    use Moose;
    extends 'Bar';
    sub BUILD { $Baz++ }
}

Baz->new;
{ local $TODO = "need to call custom constructor for other classes, not Moose::Object->new";
is($Foo, 1, "Foo->new is called");
}
{ local $TODO = "need to call non-Moose constructor, not superclass constructor";
is($Bar, 0, "Bar->new is not called");
}
is($Baz, 1, "Baz->new is called");

Baz->meta->make_immutable;
($Foo, $Bar, $Baz) = (0, 0, 0);

Baz->new;
is($Foo, 1, "Foo->new is called");
{ local $TODO = "need to call non-Moose constructor, not superclass constructor";
is($Bar, 0, "Bar->new is not called");
}
is($Baz, 1, "Baz->new is called");