#!perl
{
method slurpy(
@that
) {
return
\
@that
}
method slurpy_required(
@that
) {
return
\
@that
}
method slurpy_last(
$this
,
@that
) {
return
$this
, \
@that
; }
ok !
eval
q[fun slurpy_first(@that, $this) { return $this, \@that; }]
;
like $@,
qr{\$this\b.+\@that\b}
;
like $@,
qr{\bslurpy_first\b}
;
ok !
eval
q[fun slurpy_middle($this, @that, $other) { return $this, \@that, $other }]
;
like $@,
qr{\$other\b.+\@that\b}
;
like $@,
qr{\bslurpy_middle\b}
;
ok !
eval
q[fun slurpy_positional(:@that) { return \@that; }]
;
like $@,
qr{\bnamed\b.+\@that\b.+\barray\b}
;
like $@,
qr{\bslurpy_positional\b}
;
ok !
eval
q[fun slurpy_two($this, @that, @other) { return $this, \@that, \@other }]
;
like $@,
qr{\@other\b.+\@that\b}
;
}
note
"Optional slurpy params accept 0 length list"
; {
is_deeply [Stuff->slurpy()], [[]];
is_deeply [Stuff->slurpy_last(23)], [23, []];
}
done_testing;