Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b27262e7e8
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 62 lines (51 sloc) 1.64 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 56 57 58 59 60 61
use v6;

use Test;

plan 13;

=begin pod

Classes with names containing double colons and nested classes.

=end pod

class Foo::Bar {
    method baz {
        return 42;
    }
}

{
    my $foobar = Foo::Bar.new();
    is($foobar.baz, 42, 'methods can be called on classes with namespaces with ::');
}

class A {
    class B {
        method x { 2 }
        has $.y = 'b';
        method z { $!y }
    };
    method x { 1 }
    has $.y = 'a';
    method z { $!y }
};
{
    ok(A.new, 'could instantiate outer class');
    is(A.new.x, 1, 'called correct method on class A');
    is(A.new.y, 'a', 'could access attribute in class A');
    is(A.new.z, 'a', 'method access correct attribute in class A');
    #?pugs 5 skip 'No such subroutine: &A::B'
    ok(A::B.new, 'could instantiate nested class');
    is(A::B.new.x, 2, 'called correct method on class A::B');
    is(A::B.new.y, 'b', 'could access attribute in class A::B');
    is(A::B.new.z, 'b', 'method access correct attribute in class A::B');
    eval_dies_ok(q{ B.new }, 'class A::B not available outside of class as B');
}

class C {
    grammar D {
        rule test { a+ }
    }
}
#?pugs skip 'No such subroutine: &C::D'
{
    ok(C::D ~~ Grammar, 'C::D is a grammar');
    #?niecza skip 'Cannot dispatch to a method on D because it is not inherited or done by Cursor'
    ok('aaa' ~~ /<C::D::test>/, 'could call rule in nested grammar');
    #?niecza skip 'Cannot dispatch to a method on D because it is not inherited or done by Cursor'
    ok(!('bbb' ~~ /<C::D::test>/), 'rule in nested grammar behaves correctly');
}

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