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 56 lines (41 sloc) 1.244 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 44 45 46 47 48 49 50 51 52 53 54 55
use v6;

use Test;

# L<S12/Interface Consistency>

plan 8;

class Foo {
    our &m1 = method m1($a) { #OK not used
        1
    }
    our &m2 = method m2($a, *%foo) { #OK not used
        %foo.keys.elems
    }
}

lives_ok { Foo.new.m1(1, :x<1>, :y<2>) }, 'implicit *%_ means we can pass extra nameds';
ok &Foo::m1.signature.perl ~~ /'*%_'/, '*%_ shows up in .perl of the Signature';
lives_ok { Foo.new.m2(1, :x<1>, :y<2>) }, 'explicit *%_ means we can pass extra nameds';
ok &Foo::m2.signature.perl !~~ /'*%_'/, 'With explicit one, *%_ not in .perl of the Signature';

class Bar is Foo is hidden {
    our &m1 = method m1($a) { #OK not used
        2
    }
}

dies_ok { Bar.new.m1(1, :x<1>, :y<2>) }, 'is hidden means no implicit *%_';
ok &Bar::m1.signature.perl !~~ /'*%_'/, '*%_ does not show up in .perl of the Signature';


class Baz is Bar {
    method m1($a) { #OK not used
        nextsame;
    }
}

is Baz.new.m1(42), 1, 'is hidden on Bar means we skip over it in deferal';


class Fiz is Foo {
    method m1($a) { #OK not used
        4
    }
}
class Faz hides Fiz {
    method m1($a) { #OK not used
        nextsame;
    }
}

is Faz.new.m1(42), 1, 'hides Fiz means we skip over Fiz in deferal';

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