update foreign tests
[p5sagit/Function-Parameters.git] / t / foreign / signatures / proto.t
CommitLineData
514bcaa6 1#!perl
2use strict;
3use warnings;
4use Test::More tests => 7;
5
6use vars qw/@warnings/;
7BEGIN { $SIG{__WARN__} = sub { push @warnings, @_ } }
8
9BEGIN { is(@warnings, 0, 'no warnings yet') }
10
11use Function::Parameters;
12
13fun with_proto ($x, $y, $z) : ($$$) {
14 return $x + $y + $z;
15}
16
17{
18 my $foo;
19 fun with_lvalue () : () lvalue { $foo }
20}
21
22is(prototype('with_proto'), '$$$', ':proto attribute');
23
24is(prototype('with_lvalue'), '', ':proto with other attributes');
25with_lvalue = 1;
26is(with_lvalue, 1, 'other attributes still there');
27
28BEGIN { is(@warnings, 0, 'no warnings with correct :proto declarations') }
29
30fun invalid_proto ($x) : (invalid) { $x }
31
32BEGIN {
3517027a 33 #TODO: {
34 # local $TODO = ':proto checks not yet implemented';
514bcaa6 35 is(@warnings, 1, 'warning with illegal :proto');
36 like(
37 $warnings[0],
38 qr/Illegal character in prototype for fun invalid_proto : invalid at /,
39 'warning looks sane',
40 );
3517027a 41 #}
514bcaa6 42}
43
1a52f2db 44#eval 'sub foo ($bar) : proto { $bar }';
45#like($@, qr/proto attribute requires argument/);