Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
We now pass 56-role.t.
  • Loading branch information
jnthn committed Feb 1, 2013
1 parent a4857d5 commit ea04fec
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions t/nqp/56-role.t
@@ -0,0 +1,40 @@
plan(13);

role R1 {
has $!a;
method role_meth() { "called role method" }
method get_attr() { $!a }
method set_attr($v) { $!a := $v }
method where() { "method in " ~ $?CLASS.HOW.name($?CLASS) }
method override_me() { "role's method - OH NO" }
}

class CL1 does R1 { }
class CL2 does R1 {
method override_me() { "class method beat role one - YAY" }
}

ok(CL1.HOW.does(CL1, R1));
ok(CL2.HOW.does(CL2, R1));

my $x := CL1.new();
ok($x.role_meth() eq "called role method");
$x.set_attr("yay composed attrs");
ok($x.get_attr() eq "yay composed attrs");

ok(CL1.where() eq "method in CL1");
ok(CL2.where() eq "method in CL2");
ok(CL2.override_me() eq "class method beat role one - YAY");


role R3 { method a() { 1 }; method c() { 'wtf' } }
role R4 { method b() { 2 }; method c() { 'wtf' } }
class C3 does R3 does R4 { method c() { 'resolved' } }
ok(C3.a() == 1);
ok(C3.b() == 2);
ok(C3.c() eq 'resolved');

ok(!C3.HOW.does(C3, R1));
ok(C3.HOW.does(C3, R3));
ok(C3.HOW.does(C3, R4));

0 comments on commit ea04fec

Please sign in to comment.