6 use Test::More tests => 11;
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');
24 eval { my @x = (1, 5); &foo(@x) };
25 is($@, '', '&foo was compiled ok');
26 is($foo, 1, '&foo was called with the right arguments');
29 sub bar (\@) { $bar = 0; $bar += $_ for grep defined, @{$_[0]} }
31 eval { my @x = (2, 3, 4); bar @x };
32 is($@, '', 'bar was compiled ok');
33 is($bar, 9, 'bar was called with the right arguments');
35 eval { my @x = ([2, 3], 4); &bar(@x) };
36 is($@, '', '&bar was compiled ok');
37 is($bar, 5, '&bar was called with the right arguments');
40 like($@, qr/^Undefined\s+subroutine\s+&?main::baz/,'baz couldn\'t be compiled');
41 is($baz, undef, 'baz can\'t be called because of the prototype mismatch');