Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 44 lines (35 sloc) 0.895 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 42 43
use v6;
use Test;
plan 5;

#L<S12/Method call vs. Subroutine call>

class test {
    method foo($a:) { 'method' } #OK not used
};
sub foo($a) { 'sub' }; #OK not used
my $obj = test.new;

#?rakudo skip 'confused near "($obj:), "'
#?niecza skip 'Invocant handling is NYI'
is foo($obj:), 'method', 'method with colon notation';
is $obj.foo, 'method', 'method with dot notation';
is foo($obj), 'sub', 'adding trailing comma should call the "sub"';

# RT #69610
{
    class RT69610 {
        our method rt69610() {
            return self;
        }
    }

    ok( { "foo" => &RT69610::rt69610 }.<foo>( RT69610.new ) ~~ RT69610,
        "Can return from method called from a hash lookup (RT 69610)" );
}

# RT #92192
#?pugs skip 'anon'
{
    my @a;
    my $n;
    for 1..5 -> $i { @a.push(anon method foo { $n++ }) };
    .($_) for @a;
    is $n, 5, 'RT #92192';
}

done;

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