Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[t] move splatty_in_caller_position.t to spec/; cleanup
git-svn-id: http://svn.pugscode.org/pugs@26209 c213334d-75ef-0310-aa23-eaa082d1ae64
- Loading branch information
moritz
committed
Apr 14, 2009
1 parent
9a6f340
commit b8fa545
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use v6; | ||
|
||
use Test; | ||
|
||
plan 4; | ||
|
||
# L<S03/Argument List Interpolating/"interpolate"> | ||
|
||
# try to flatten the args for baz() to match | ||
|
||
sub baz ($a, $b) { return "a: $a b: $b"} | ||
sub invoke (*@args) { baz(|@args) } | ||
|
||
my $val; | ||
lives_ok { | ||
$val = invoke(1, 2); | ||
}, '... slurpy args flattening and matching parameters'; | ||
|
||
is($val, 'a: 1 b: 2', '... slurpy args flattening and matching parameters'); | ||
|
||
# try to flatten the args for the anon sub to match | ||
|
||
sub invoke2 ($f, *@args) { $f(|@args) }; | ||
is(invoke2(sub ($a, $b) { return "a: $a b: $b"}, 1, 2), 'a: 1 b: 2', | ||
'... slurpy args flattening and matching parameters'); | ||
|
||
dies_ok { | ||
invoke2(sub ($a, $b) { return "a: $a b: $b"}, 1, 2, 3); | ||
}, '... slurpy args flattening and not matching because of too many parameters'; |