Skip to content

Commit

Permalink
[spectest] A couple more mixin tests, for does (R1, R2) and does Answ…
Browse files Browse the repository at this point in the history
…er(42) usage.

git-svn-id: http://svn.pugscode.org/pugs@20894 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
jnthn committed Jun 19, 2008
1 parent 9cdf717 commit 720c254
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions S12-role/mixin.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 6;
plan 11;

role R1 { method test { 42 } }
class C1 { }
Expand All @@ -21,11 +21,26 @@ is $y.x, 100, 'mixing in did not destroy old value';

role R3 { has $.answer is rw }
class C3 { has $.x }
my $y = C3.new(x => 100);
$y = C3.new(x => 100);
$y does R3;
$y.answer = 42;
is $y.x, 100, 'mixing in with attributes did not destroy existing ones';
is $y.answer, 42, 'mixed in new attributes';


$y = C3.new(x => 100);
$y does (R2, R3);
$y.answer = 13;
is $y.x, 100, 'multi-role mixin preserved existing values';
is $y.answer, 13, 'attribute from multi-role mixing OK';
is $y.test, 42, 'method from other role was OK too';


role Answer { has $.answer is rw }
$x = 0;
$x does Answer(42);
is $x.answer, 42, 'role mix-in with initialization value worked';
is $x, 0, 'mixing into Int still makes it function as an Int';


# vim: syn=perl6

0 comments on commit 720c254

Please sign in to comment.