summaryrefslogtreecommitdiff
path: root/t/basics/super_warns_on_args.t
blob: 3600d9f25f18f124c4369bf0e520cf9867ea5482 (plain)
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
use strict;
use warnings;

use Test::Requires 'Test::Output';
use Test::More;

{
    package Parent;
    use Moose;

    sub foo { 42 }
    sub bar { 42 }

    package Child;
    use Moose;

    extends 'Parent';

    override foo => sub {
        super( 1, 2, 3 );
    };

    override bar => sub {
        super();
    };
}

{
    my $file = __FILE__;

    stderr_like(
        sub { Child->new->foo },
        qr/\QArguments passed to super() are ignored at $file/,
        'got a warning when passing args to super() call'
    );

    stderr_is(
        sub { Child->new->bar },
        q{},
        'no warning on super() call without arguments'
    );
}

done_testing();