<commit_before>use v6;

use Test;

plan 10;

# The :() form constructs signatures similar to how \() constructs Captures.
# A subroutine's .signature is a Siglist object.

#L<S02/Names and Variables/"A signature object">

{
    my $a;
    ok :($a) ~~ Signature, ':($a) create a Signature object';
    :($a) := 3;
    is $a, 3, 'can bind to one-element signature';
    dies_ok { $a++ }, 'cannot increment an Int';
}


{
    my ($x, $y, $z);
    :($x,$y,$z); := (1,2,3);
    is("$x $y $z", "1 2 3", "siglist bindings works");
}

# Same, but more complex
{
    my ($x, @y, @rest);
    :($x,@y,*@rest); := (42,[13,17],5,6,7);
    #?pugs todo 'feature'
    is("$x!{@y}!{@rest}", "42!13 17!5 6 7", "complex siglist bindings works (1)");
}

{
    my ($x);
    :($x?) := ();
    ok(!$x.defined, "complex siglist bindings works (2)");
}

# &sub.signature should return a Siglist object
{
    sub foo1 ($a, $b) {}
    my $siglist = :($a, $b);

    ok ~$siglist,
        "a siglist stringifies";
    #?pugs todo 'feature'
    ok $siglist eqv &foo1.signature,
        "a subroutine's siglist can be accessed via .signature (1)";
}

# Same as above, but more complex
{
    my sub foo (Num $a, $b?, *@rest) {}
    my $siglist = :(Num $a, $b?, *@rest);

    #?pugs todo 'feature'
    ok $siglist eqv &foo.signature ,
        "a subroutine's siglist can be accessed via .signature (2)";
}

{
    my sub foo ($a, $b) {}
    my $siglist = :($a);

    ok $siglist !eqv &foo.signature,
        "a subroutine's siglist can be accessed via .signature (3)";
}

# vim: ft=perl6
<commit_msg>[signature.t] remove Sorry!<commit_after>use v6;

use Test;

plan 10;

# The :() form constructs signatures similar to how \() constructs Captures.
# A subroutine's .signature is a Siglist object.

#L<S02/Names and Variables/"A signature object">

{
    my $a;
    ok :($a) ~~ Signature, ':($a) create a Signature object';
    :($a) := 3;
    is $a, 3, 'can bind to one-element signature';
    dies_ok { $a++ }, 'cannot increment an Int';
}


{
    my ($x, $y, $z);
    :($x,$y,$z) := (1,2,3);
    is("$x $y $z", "1 2 3", "siglist bindings works");
}

# Same, but more complex
{
    my ($x, @y, @rest);
    :($x,@y,*@rest) := (42,[13,17],5,6,7);
    #?pugs todo 'feature'
    is("$x!{@y}!{@rest}", "42!13 17!5 6 7", "complex siglist bindings works (1)");
}

{
    my ($x);
    :($x?) := ();
    ok(!$x.defined, "complex siglist bindings works (2)");
}

# &sub.signature should return a Siglist object
{
    sub foo1 ($a, $b) {}
    my $siglist = :($a, $b);

    ok ~$siglist,
        "a siglist stringifies";
    #?pugs todo 'feature'
    ok $siglist eqv &foo1.signature,
        "a subroutine's siglist can be accessed via .signature (1)";
}

# Same as above, but more complex
{
    my sub foo (Num $a, $b?, *@rest) {}
    my $siglist = :(Num $a, $b?, *@rest);

    #?pugs todo 'feature'
    ok $siglist eqv &foo.signature ,
        "a subroutine's siglist can be accessed via .signature (2)";
}

{
    my sub foo ($a, $b) {}
    my $siglist = :($a);

    ok $siglist !eqv &foo.signature,
        "a subroutine's siglist can be accessed via .signature (3)";
}

# vim: ft=perl6

{'fraction_non_alphanumeric': 0.1984732824427481, 'fraction_numerical': 0.02480916030534351, 'mean_word_length': 2.901985111662531, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5545313', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1218, 'n_words': 390}