<commit_before>use v6;
use Test;

plan 15;

# L<S06/Perl5ish subroutine declarations/You can declare a sub without
# parameter list>

sub simple { 'simple' }
#?rakudo skip 'siglist'
is &simple.signature, :(), 'signature is :() when none is specified';
is simple(), 'simple', 'can call sub with no signature specified';
dies_ok { simple( :golf<hotel> ) },
        'sub with no signature dies when given a named argument';
dies_ok { simple( 'india' ) },
        'sub with no signature dies when given positional argument';

sub positional { @_[0] }
#?rakudo skip 'siglist'
is &positional.signature, :(Mu *@_),
   'signature is :(Mu *@_) when none is specified and @_ is used';
is positional( 'alpha' ), 'alpha', 'can call sub with positional param used';
ok positional().notdef, 'sub using positional param called with no params';
dies_ok { positional( :victor<whiskey> ) },
   'sub using positional param called with named param';

sub named { %_<bravo> }
#?rakudo skip 'siglist'
is &named.signature, :(Mu *%_),
   'signature is :(Mu *%_) when none is specified and %_ is used';
is named( :bravo<charlie> ), 'charlie', 'can call sub with named param used';
ok named().notdef, 'named param sub is callable with no params';
dies_ok { named( 'zulu' ) }, 'named param sub dies with positional param';

sub both { @_[1] ~ %_<delta> }
#?rakudo skip 'siglist'
is &both.signature, :(Mu *@_, Mu *%_),
   'signature is :(Mu *@_, Mu *%_) when none is specified and @_ and %_ are used';
is both( 'x', :delta<echo>, 'foxtrot' ), 'foxtrotecho',
   'can call sub with both named and positional params used';
is both(), '',
   'sub using both named and position params works with no params';

# vim: ft=perl6<commit_msg>[t/spec] Test for RT 71112: Cannot assign to readonly variable.<commit_after>use v6;
use Test;

plan *;

# L<S06/Perl5ish subroutine declarations/You can declare a sub without
# parameter list>

sub simple { 'simple' }
#?rakudo skip 'siglist'
is &simple.signature, :(), 'signature is :() when none is specified';
is simple(), 'simple', 'can call sub with no signature specified';
dies_ok { simple( :golf<hotel> ) },
        'sub with no signature dies when given a named argument';
dies_ok { simple( 'india' ) },
        'sub with no signature dies when given positional argument';

sub positional { @_[0] }
#?rakudo skip 'siglist'
is &positional.signature, :(Mu *@_),
   'signature is :(Mu *@_) when none is specified and @_ is used';
is positional( 'alpha' ), 'alpha', 'can call sub with positional param used';
ok positional().notdef, 'sub using positional param called with no params';
dies_ok { positional( :victor<whiskey> ) },
   'sub using positional param called with named param';

sub named { %_<bravo> }
#?rakudo skip 'siglist'
is &named.signature, :(Mu *%_),
   'signature is :(Mu *%_) when none is specified and %_ is used';
is named( :bravo<charlie> ), 'charlie', 'can call sub with named param used';
ok named().notdef, 'named param sub is callable with no params';
dies_ok { named( 'zulu' ) }, 'named param sub dies with positional param';

sub both { @_[1] ~ %_<delta> }
#?rakudo skip 'siglist'
is &both.signature, :(Mu *@_, Mu *%_),
   'signature is :(Mu *@_, Mu *%_) when none is specified and @_ and %_ are used';
is both( 'x', :delta<echo>, 'foxtrot' ), 'foxtrotecho',
   'can call sub with both named and positional params used';
is both(), '',
   'sub using both named and position params works with no params';

# RT 71112
{
    sub rt71112 { @_[0] = 'bug' }
    my $tender = 'sanity';
    #?rakudo todo 'RT 71112: Cannot assign to readonly variable.'
    dies_ok { rt71112( $tender ) }, 'Sub that tries to modify @_ dies';
    is $tender, 'sanity', 'The variable passed is unchanged.';
}

done_testing;

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.1424759871931697, 'fraction_numerical': 0.011205976520811099, 'mean_word_length': 4.3328591749644385, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857685', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1202, 'n_words': 485}