3 use lib 'lib', 't/role-basic/lib';
5 require Role::Tiny::Restricted;
8 package My::Does::Basic;
10 use Role::Tiny::Restricted;
12 requires 'turbo_charger';
15 return "My::Does::Basic::conflict";
20 package My::Bad::MultipleWith;
21 use Role::Tiny::Restricted::With;
22 with 'My::Does::Basic';
23 with 'My::Does::Basic'; # can't use with() more than once
27 qr/with\(\) may not be called more than once for My::Bad::MultipleWith/,
28 'Trying to use with() more than once in a package should fail';
31 package My::Bad::Requirement;
32 use Role::Tiny::Restricted::With;
33 with 'My::Does::Basic'; # requires turbo_charger
36 qr/missing turbo_charger/,
37 'Trying to use a role without providing required methods should fail';
42 use Role::Tiny::Restricted;
45 eval <<' END_PACKAGE';
46 package My::Bad::MethodConflicts;
47 use Role::Tiny::Restricted::With;
48 with qw(My::Does::Basic My::Conflict);
53 'Trying to use multiple roles with the same method should fail';
60 use Role::Tiny::Restricted;
61 requires 'missing_method';
62 sub method1 { 'method1' }
66 use Role::Tiny::Restricted;
68 sub method2 { 'method2' }
71 package My::Class::Missing1;
72 use Role::Tiny::Restricted::With;
76 qr/missing missing_method/,
77 'Roles composed from roles should propogate requirements upwards';
82 use Role::Tiny::Restricted;
83 requires qw(this that);
86 package My::Class::Missing2;
87 use Role::Tiny::Restricted::With;
91 qr/missing this, that/,
92 'Roles should be able to require multiple methods';