6 use Test::More tests => 15;
11 use_ok('Moose::Role');
16 The idea and examples for this feature are taken
17 from the Fortress spec.
19 http://research.sun.com/projects/plrg/fortress0903.pdf
21 trait OrganicMolecule extends Molecule
22 excludes { InorganicMolecule }
24 trait InorganicMolecule extends Molecule end
34 package Molecule::Organic;
40 excludes 'Molecule::Inorganic';
42 package Molecule::Inorganic;
50 ok(Molecule::Organic->meta->excludes_role('Molecule::Inorganic'), '... Molecule::Organic exludes Molecule::Inorganic');
52 [ Molecule::Organic->meta->get_excluded_roles_list() ],
53 [ 'Molecule::Inorganic' ],
54 '... Molecule::Organic exludes Molecule::Inorganic');
63 with 'Molecule::Organic';
64 } '... adding the role (w/ excluded roles) okay';
72 with 'Molecule::Organic', 'Molecule::Inorganic';
73 } qr/Conflict detected: Class::MOP::Class::__ANON__::SERIAL::1 excludes role \'Molecule::Inorganic\'/,
74 '... adding the role w/ excluded role conflict dies okay';
82 with 'Molecule::Organic';
83 } '... adding the role (w/ excluded roles) okay';
86 with 'Molecule::Inorganic';
87 } qr/Conflict detected: My::Test3 excludes role 'Molecule::Inorganic'/,
88 '... adding the role w/ excluded role conflict dies okay';
91 ok(My::Test1->does('Molecule::Organic'), '... My::Test1 does Molecule::Organic');
92 ok(My::Test1->meta->excludes_role('Molecule::Inorganic'), '... My::Test1 excludes Molecule::Organic');
93 ok(!My::Test2->does('Molecule::Organic'), '... ! My::Test2 does Molecule::Organic');
94 ok(!My::Test2->does('Molecule::Inorganic'), '... ! My::Test2 does Molecule::Inorganic');
95 ok(My::Test3->does('Molecule::Organic'), '... My::Test3 does Molecule::Organic');
96 ok(My::Test3->meta->excludes_role('Molecule::Inorganic'), '... My::Test3 excludes Molecule::Organic');
97 ok(!My::Test3->does('Molecule::Inorganic'), '... ! My::Test3 does Molecule::Inorganic');