3 # Test slurpy parameters
6 use warnings FATAL => 'all';
12 use Function::Parameters qw(:strict);
15 method slurpy(@that) { return \@that }
16 method slurpy_required(@that) { return \@that }
17 method slurpy_last($this, @that) { return $this, \@that; }
19 ok !eval q[fun slurpy_first(@that, $this) { return $this, \@that; }];
20 like $@, qr{\@that\b.+\$this\b};
22 #local $TODO = "error message incorrect inside an eval";
24 like $@, qr{\bslurpy_first\b};
27 ok !eval q[fun slurpy_middle($this, @that, $other) { return $this, \@that, $other }];
28 like $@, qr{\@that\b.+\$other\b};
30 #local $TODO = "error message incorrect inside an eval";
32 like $@, qr{\bslurpy_middle\b};
35 ok !eval q[fun slurpy_positional(:@that) { return \@that; }];
36 like $@, qr{\bnamed\b.+\@that\b.+\barray\b};
38 ok !eval q[fun slurpy_two($this, @that, @other) { return $this, \@that, \@other }];
39 like $@, qr{\@that\b.+\@other\b};
43 note "Optional slurpy params accept 0 length list"; {
44 is_deeply [Stuff->slurpy()], [[]];
45 is_deeply [Stuff->slurpy_last(23)], [23, []];
48 #note "Required slurpy params require an argument"; {
49 # throws_ok { Stuff->slurpy_required() }
50 # qr{slurpy_required\Q()\E, missing required argument \@that at \Q$0\E line @{[__LINE__ - 1]}};