From: Dave Rolsky Date: Sat, 26 May 2012 21:52:38 +0000 (-0500) Subject: Add test for new warning - super() warns if it is passed arguments X-Git-Tag: 2.0800~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f34ddc509794eac429c1373e2072f5c3d39a8f47;p=gitmo%2FMoose.git Add test for new warning - super() warns if it is passed arguments --- diff --git a/t/basics/super_warns_on_args.t b/t/basics/super_warns_on_args.t new file mode 100644 index 0000000..3705ee8 --- /dev/null +++ b/t/basics/super_warns_on_args.t @@ -0,0 +1,47 @@ +use strict; +use warnings; + +use Test::Requires { + 'Test::Output' => '0.01', +}; + +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();