Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (21 sloc) 795 Bytes
role TheRole {
has $!a;
method role_meth() { "called role method" }
method get_attr() { $!a }
method set_attr($v) { $!a := $v }
method override_me() { "role method" }
class Example {
method override_me() { "class method" }
my $obj :=;
my $obj_m :=;
ok($obj.override_me() eq "class method", "sanity (1)");
ok($obj_m.override_me() eq "class method", "sanity (2)");
$obj_m.HOW.mixin($obj_m, TheRole);
ok($obj_m.role_meth() eq "called role method", "role method mxied in");
ok($obj_m.get_attr() eq "stout", "attributes from role work properly");
ok($obj_m.override_me() eq "role method", "mixed in method overrides original one");
ok($obj.override_me() eq "class method", "mixing in is per object");
Something went wrong with that request. Please try again.