Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
initial tests for composing roles with stubbed methods
  • Loading branch information
moritz committed Dec 19, 2011
1 parent 4c68d1a commit 21e85ed
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions S14-roles/stubs.t
@@ -0,0 +1,22 @@
use v6;
use Test;

plan 6;

role WithStub { method a() { ... } };
role ProvidesStub1 { method a() { 1 } };
role ProvidesStub2 { method a() { 2 } };

dies_ok { eval 'class A does WithStub { }' },
'need to implement stubbed methods at role-into-class composition time';
lives_ok { eval 'role B does WithStub { }' },
'but roles are fine';
lives_ok { eval 'class C does WithStub { method a() { 3 } }' },
'directly implementing the stubbed method is fine';
lives_ok { eval 'class D does WithStub does ProvidesStub1 { }' },
'composing the stubbed method is fine';
dies_ok { eval 'class E does WithStub does ProvidesStub1 does ProvidesStub2 { }' },
'composing stub and 2 implementations dies again';
lives_ok { eval 'class F does WithStub does ProvidesStub1 does ProvidesStub2 {
method a() { 4 } }' },
'composing stub and 2 implementations allows custom implementation';

0 comments on commit 21e85ed

Please sign in to comment.