3 # Test slurpy parameters
6 use warnings FATAL => 'all';
13 use Function::Parameters qw(:strict);
16 method slurpy(@that) { return \@that }
17 method slurpy_required(@that) { return \@that }
18 method slurpy_last($this, @that) { return $this, \@that; }
20 ok !eval q[fun slurpy_first(@that, $this) { return $this, \@that; }];
21 like $@, qr{\@that\b.+\$this\b};
23 # local $TODO = "error message incorrect inside an eval";
25 # like $@, qr{Stuff::};
26 like $@, qr{\bslurpy_first\b};
29 ok !eval q[fun slurpy_middle($this, @that, $other) { return $this, \@that, $other }];
30 like $@, qr{\@that\b.+\$other\b};
32 # local $TODO = "error message incorrect inside an eval";
34 # like $@, qr{Stuff::};
35 like $@, qr{\bslurpy_middle\b};
38 ok !eval q[fun slurpy_positional(:@that) { return \@that; }];
39 like $@, qr{\bnamed\b.+\@that\b.+\barray\b};
42 # local $TODO = "error message incorrect inside an eval";
44 # like $@, qr{Stuff::};
45 like $@, qr{\bslurpy_positional\b};
48 ok !eval q[fun slurpy_two($this, @that, @other) { return $this, \@that, \@other }];
49 like $@, qr{\@that\b.+\@other\b};
53 note "Optional slurpy params accept 0 length list"; {
54 is_deeply [Stuff->slurpy()], [[]];
55 is_deeply [Stuff->slurpy_last(23)], [23, []];
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]}};