Add test for new warning - super() warns if it is passed arguments
[gitmo/Moose.git] / t / basics / super_warns_on_args.t
1 use strict;
2 use warnings;
3
4 use Test::Requires {
5     'Test::Output' => '0.01',
6 };
7
8 use Test::More;
9
10 {
11     package Parent;
12     use Moose;
13
14     sub foo { 42 }
15     sub bar { 42 }
16
17     package Child;
18     use Moose;
19
20     extends 'Parent';
21
22     override foo => sub {
23         super( 1, 2, 3 );
24     };
25
26     override bar => sub {
27         super();
28     };
29 }
30
31 {
32     my $file = __FILE__;
33
34     stderr_like(
35         sub { Child->new->foo },
36         qr/\QArguments passed to super() are ignored at $file/,
37         'got a warning when passing args to super() call'
38     );
39
40     stderr_is(
41         sub { Child->new->bar },
42         q{},
43         'no warning on super() call without arguments'
44     );
45 }
46
47 done_testing();