Perl6-Signature

 view release on metacpan or  search on metacpan

t/02-simple.t  view on Meta::CPAN

        , ':(:short($long)?)',    ':(:short($long))',     'optional long named, explicit "?"'
        , ':(*@x, $y)',           ':($y, *@x)',           'slurpy array and positional'
        , ':(*%x, $y)',           ':($y, *%x)',           'slurpy hash and positional'
        , ':(*%x, $y, *@x)',      ':($y, *@x, *%x)',      'slurpy hash and positional'
        , ':(Int | Str $x)',      ':(Int|Str $x)',        'type constraint alternative with whitespce'
        );
    while (my ($sig, $canonical, $desc) = splice @sigs, 0, 3) {
        lives_and { is(Perl6::Signature->parse($sig)->to_string, $canonical) } "(altspace) $desc";
    }

    my @badsigs =
        ( ':($x?:)',              'optional invocant'
        , ':($x?, $y)',           'required positional after optional one'
        , ':(Int| $x)',           'invalid type alternation',
        , ':(|Int $x)',           'invalid type alternation',
        );
    while (my ($badsig, $desc) = splice @badsigs, 0, 2) {
        dies_ok { Perl6::Signature->parse($badsig) } "(badsig) $desc";
    }
}

# vim:ft=perl:



( run in 2.675 seconds using v1.01-cache-2.11-cpan-71847e10f99 )