Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] We now pass 22-optional-args.t.
- Loading branch information
Showing
1 changed file
with
30 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,30 @@ | ||
#! nqp | ||
|
||
# test optional arguments and parameters | ||
|
||
plan(3); | ||
|
||
sub f1 ($x, $y!, $z?) { | ||
$x; | ||
} | ||
say('ok ', f1(1, 2), ' # optional args ignorable'); | ||
say('ok ', f1(2, 2, 2), ' # optional args passable'); | ||
|
||
sub f2 ($x?, $y?) { 'ok 3 # only optional args'; } | ||
say(f2()); | ||
|
||
# TODO we can't parse .defined() yet - jg | ||
#sub f3 ($x, $y?, $text?) { | ||
# if ! $y.defined() && ! $text.defined() { | ||
# say('ok 4 # unpassed optional args are undef'); | ||
# } else { | ||
# say('ok ', $x - $y, $text); | ||
# } | ||
#} | ||
#f3(2); | ||
#f3(8, 3, ' # optional args get passed values'); | ||
#f3(8, :text(' # optional args specifiable by name'), :y(2)); | ||
|
||
# XXX: need to be able to test that the following is illegal | ||
#sub f4 ($x?, $y) { $y; } | ||
|