Add test for new warning - super() warns if it is passed arguments
Dave Rolsky [Sat, 26 May 2012 21:52:38 +0000 (16:52 -0500)]
t/basics/super_warns_on_args.t [new file with mode: 0644]

diff --git a/t/basics/super_warns_on_args.t b/t/basics/super_warns_on_args.t
new file mode 100644 (file)
index 0000000..3705ee8
--- /dev/null
@@ -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();