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{slurpy parameter \@that cannot be named, use a reference instead};
39 # local $TODO = "error message incorrect inside an eval";
41 # like $@, qr{Stuff::};
42 # like $@, qr{slurpy_positional\(\)};
45 ok !eval q[fun slurpy_two($this, @that, @other) { return $this, \@that, \@other }];
46 like $@, qr{\@that\b.+\@other\b};
50 note "Optional slurpy params accept 0 length list"; {
51 is_deeply [Stuff->slurpy()], [[]];
52 is_deeply [Stuff->slurpy_last(23)], [23, []];
55 #note "Required slurpy params require an argument"; {
56 # throws_ok { Stuff->slurpy_required() }
57 # qr{slurpy_required\Q()\E, missing required argument \@that at \Q$0\E line @{[__LINE__ - 1]}};