update foreign tests
[p5sagit/Function-Parameters.git] / t / foreign / Method-Signatures / slurpy.t
CommitLineData
633048d5 1#!perl
2
3# Test slurpy parameters
4
5use strict;
6use warnings FATAL => 'all';
7
8use Test::More;
1a52f2db 9#use Test::Exception;
633048d5 10
11{
12 package Stuff;
13 use Function::Parameters qw(:strict);
14 use Test::More;
15
16 method slurpy(@that) { return \@that }
17 method slurpy_required(@that) { return \@that }
18 method slurpy_last($this, @that) { return $this, \@that; }
19
20 ok !eval q[fun slurpy_first(@that, $this) { return $this, \@that; }];
21 like $@, qr{\@that\b.+\$this\b};
1a52f2db 22# TODO: {
23# local $TODO = "error message incorrect inside an eval";
633048d5 24
1a52f2db 25# like $@, qr{Stuff::};
633048d5 26 like $@, qr{\bslurpy_first\b};
1a52f2db 27# }
633048d5 28
29 ok !eval q[fun slurpy_middle($this, @that, $other) { return $this, \@that, $other }];
30 like $@, qr{\@that\b.+\$other\b};
1a52f2db 31# TODO: {
32# local $TODO = "error message incorrect inside an eval";
633048d5 33
1a52f2db 34# like $@, qr{Stuff::};
633048d5 35 like $@, qr{\bslurpy_middle\b};
1a52f2db 36# }
633048d5 37
98e6239b 38 ok !eval q[fun slurpy_positional(:@that) { return \@that; }];
39 like $@, qr{\bnamed\b.+\@that\b.+\barray\b};
633048d5 40
1a52f2db 41# TODO: {
42# local $TODO = "error message incorrect inside an eval";
43
44# like $@, qr{Stuff::};
45 like $@, qr{\bslurpy_positional\b};
46# }
47
633048d5 48 ok !eval q[fun slurpy_two($this, @that, @other) { return $this, \@that, \@other }];
49 like $@, qr{\@that\b.+\@other\b};
50}
51
52
53note "Optional slurpy params accept 0 length list"; {
54 is_deeply [Stuff->slurpy()], [[]];
55 is_deeply [Stuff->slurpy_last(23)], [23, []];
56}
57
58#note "Required slurpy params require an argument"; {
59# throws_ok { Stuff->slurpy_required() }
60# qr{slurpy_required\Q()\E, missing required argument \@that at \Q$0\E line @{[__LINE__ - 1]}};
61#}
62
63
64done_testing;