From aa37f0f70bc538b90eb6ab3f27840e849294e4af Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Thu, 21 Oct 2010 01:22:02 +0200 Subject: [PATCH] [dotnet] We now pass 22-optional-args.t. --- t/nqp/22-optional-args.t | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 t/nqp/22-optional-args.t diff --git a/t/nqp/22-optional-args.t b/t/nqp/22-optional-args.t new file mode 100644 index 0000000..ae199d6 --- /dev/null +++ b/t/nqp/22-optional-args.t @@ -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; } +