Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: froggs_mergemu…
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 44 lines (33 sloc) 1.677 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use v6;
use Test;

plan 8;

# L<S14/Traits/>

role description {
    has $.description is rw;
}

multi trait_mod:<is>(Mu:U $c, description, $arg) {
    $c.HOW does description($arg);
}
multi trait_mod:<is>(Mu:U $c, description) {
    $c.HOW does description("missing description!");
}
multi trait_mod:<is>(Mu:U $c, :$described!) {
    $c.HOW does description($described ~~ Str ?? $described !! "missing description");
}

class Monkey is description('eats bananas, awesome') { }
class Walrus is description { }
is Monkey.HOW.description, 'eats bananas, awesome', 'description role applied to class and set with argument';
is Walrus.HOW.description, 'missing description!', 'description role applied to class without argument';

class Badger is described('mushroom mushroom') { }
class Snake is described { }
is Badger.HOW.description, 'mushroom mushroom', 'named trait handler applied other role to class set with argument';
is Snake.HOW.description, 'missing description!', 'named trait handler applied other role to class without argument';


role Nom is description('eats and eats') { }
role Loser is description { }
is Nom.HOW.description, 'eats and eats', 'description role applied to role and set with argument';
is Loser.HOW.description, 'missing description!', 'description role applied to role without argument';

role DamBuilding is described('dam good!') { }
role Slither is described { }
is DamBuilding.HOW.description, 'dam good!', 'named trait handler applied other role to role set with argument';
is Slither.HOW.description, 'missing description!', 'named trait handler applied other role to role without argument';

# vim: ft=perl6
Something went wrong with that request. Please try again.