Skip to content

Commit

Permalink
Pass 23-named-args.t.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jan 29, 2013
1 parent 986536a commit a22c3ce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions t/nqp/23-named-args.t
@@ -0,0 +1,23 @@
#! nqp

# test named parameters and arguments

plan(5);

sub f1 ($x, :$y) { $x - $y; }
say('ok ', f1(2, :y(1)), ' # named args passable');

sub f2 ($x, :$y) { $x; }
say('ok ', f2(2), ' # named args ignorable');

sub f3 (:$x, :$y) { $x - $y; }
say('ok ', f3(:y(2), :x(5)), ' # args reorderable');

sub f4 ($w, $x, :$y, :$z) { $w + $x + $y + $z; }
say('ok ', f4(:z(2), -3, :y(1), 4), ' # named/positional intermixable');

my $y := 5;
say('ok ', f1(10, :$y), ' - :$x colonpair syntax');


# XXX: test mandatory named args are actually mandatory

0 comments on commit a22c3ce

Please sign in to comment.