6 use Test::More tests => 22;
11 The idea and examples for this feature are taken
12 from the Fortress spec.
14 http://research.sun.com/projects/plrg/fortress0903.pdf
16 trait OrganicMolecule extends Molecule
17 excludes { InorganicMolecule }
19 trait InorganicMolecule extends Molecule end
27 package Molecule::Organic;
31 excludes 'Molecule::Inorganic';
33 package Molecule::Inorganic;
39 ok(Molecule::Organic->meta->excludes_role('Molecule::Inorganic'), '... Molecule::Organic exludes Molecule::Inorganic');
41 [ Molecule::Organic->meta->get_excluded_roles_list() ],
42 [ 'Molecule::Inorganic' ],
43 '... Molecule::Organic exludes Molecule::Inorganic');
47 Check some basic conflicts when combining
48 the roles into the same class
57 with 'Molecule::Organic';
58 } '... adding the role (w/ excluded roles) okay';
64 with 'Molecule::Organic', 'Molecule::Inorganic';
65 } qr/Conflict detected: Role Molecule::Organic excludes role 'Molecule::Inorganic'/,
66 '... adding the role w/ excluded role conflict dies okay';
72 with 'Molecule::Organic';
73 } '... adding the role (w/ excluded roles) okay';
76 with 'Molecule::Inorganic';
77 } qr/Conflict detected: My::Test3 excludes role 'Molecule::Inorganic'/,
78 '... adding the role w/ excluded role conflict dies okay';
81 ok(My::Test1->does('Molecule::Organic'), '... My::Test1 does Molecule::Organic');
82 ok(My::Test1->does('Molecule'), '... My::Test1 does Molecule');
83 ok(My::Test1->meta->excludes_role('Molecule::Inorganic'), '... My::Test1 excludes Molecule::Organic');
85 ok(!My::Test2->does('Molecule::Organic'), '... ! My::Test2 does Molecule::Organic');
86 ok(!My::Test2->does('Molecule::Inorganic'), '... ! My::Test2 does Molecule::Inorganic');
88 ok(My::Test3->does('Molecule::Organic'), '... My::Test3 does Molecule::Organic');
89 ok(My::Test3->does('Molecule'), '... My::Test1 does Molecule');
90 ok(My::Test3->meta->excludes_role('Molecule::Inorganic'), '... My::Test3 excludes Molecule::Organic');
91 ok(!My::Test3->does('Molecule::Inorganic'), '... ! My::Test3 does Molecule::Inorganic');
95 Check some basic conflicts when combining
96 the roles into the a superclass
104 with 'Molecule::Organic';
112 with 'Molecule::Inorganic';
113 } qr/Conflict detected: My::Test4 excludes role \'Molecule::Inorganic\'/,
114 '... cannot add exculded role into class which extends Methane';
117 ok(Methane->does('Molecule::Organic'), '... Methane does Molecule::Organic');
118 ok(My::Test4->isa('Methane'), '... My::Test4 isa Methane');
119 ok(My::Test4->does('Molecule::Organic'), '... My::Test4 does Molecule::Organic');
120 ok(My::Test4->meta->does_role('Molecule::Organic'), '... My::Test4 meat does_role Molecule::Organic');
121 ok(My::Test4->meta->excludes_role('Molecule::Inorganic'), '... My::Test4 meta excludes Molecule::Organic');
122 ok(!My::Test4->does('Molecule::Inorganic'), '... My::Test4 does Molecule::Inorganic');