Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
We now pass 61-mixin.t.
  • Loading branch information
jnthn committed Feb 1, 2013
1 parent 2d29fc4 commit 3fdbbd0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions t/nqp/61-mixin.t
@@ -0,0 +1,29 @@
plan(6);

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 := Example.new();
my $obj_m := Example.new();

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");

$obj_m.set_attr("stout");
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");

0 comments on commit 3fdbbd0

Please sign in to comment.