Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 41 lines (30 sloc) 0.897 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
use v6;
use Test;

plan 8;

#L<S06/Placeholder variables/>

sub positional_slurpy {
    is @_[0], 1, "Leftover positional args get passed to @_ if present";
    is +@_, 1, 'one item filled into @_';
}

positional_slurpy(1);

sub named_slurpy {
    is %_<a>, 1, "Leftover named args get passed to %_ if present";
}

named_slurpy(:a(1));

sub both {
    is @_[1], 3, "Positional and named placeholder slurpies play well together";
    is %_<a>, 4, "Positional and named placeholder slurpies play well together";
    is @_[0], 5, "Positional and named placeholder slurpies play well together";
    is %_<b>, 6, "Positional and named placeholder slurpies play well together";
}

both(5, :b(6), 3, :a(4));

{
    my @result;
    sub perl5sub {
        push @result, @_[0];
        push @result, @_[1];
    }
    perl5sub(<foo bar>);
    is(@result, [<foo bar>], 'use @_ in sub');
}


# vim: syn=perl6
Something went wrong with that request. Please try again.