6 use Test::More tests => 7;
9 sub foo ($) { $foo = $_[0] };
13 use warnings qw/FATAL redefine prototype/;
14 sub main::baz ($) { $baz = $_[0] }
16 like($@, qr/Prototype\s+mismatch\s*:\s+sub\s+main::baz\s*:\s+none\s+vs\s+\(\$\)/, 'baz appears as prototyped');
20 eval { my @x = (1, 5); foo @x };
21 is($@, '', 'foo was compiled ok');
22 is($foo, 2, 'foo was called with the right arguments');
25 sub bar (\@) { $bar = 0; $bar += $_ for grep defined, @{$_[0]} }
27 eval { my @x = (2, 3, 4); bar @x };
28 is($@, '', 'bar was compiled ok');
29 is($bar, 9, 'bar was called with the right arguments');
32 like($@, qr/^Undefined\s+subroutine\s+&?main::baz/,'baz couldn\'t be compiled');
33 is($baz, undef, 'baz can\'t be called because of the prototype mismatch');