summaryrefslogtreecommitdiffstats
path: root/t/no-new-constructor-error.t
blob: 2becbceb5e89a141f2742f3e3f4f6c9b9b4e34ef (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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

{
    package NonMoose;
    sub create { bless {}, shift }
    sub DESTROY { }
}

{
    package Child;
    use Moose;
    use MooseX::NonMoose;
    extends 'NonMoose';
    {
        my $warning;
        local $SIG{__WARN__} = sub { $warning = $_[0] };
        __PACKAGE__->meta->make_immutable;
        ::like(
            $warning,
            qr/Not inlining.*doesn't contain a constructor named 'new'/,
            "warning when trying to make_immutable without a superclass 'new'"
        );
    }
}

{
    package ChildTwo;
    use Moose;
    use MooseX::NonMoose;
    extends 'NonMoose';
    {
        my $warning;
        local $SIG{__WARN__} = sub { $warning = $_[0] };
        __PACKAGE__->meta->make_immutable(inline_constructor => 0);
        ::is($warning, undef,
            "no warning when trying to make_immutable(inline_constructor => 0) without a superclass 'new'");
    }
}

done_testing;