3 use lib 'lib', 't/role-basic/lib';
6 # multiple roles with the same role
25 use Role::Tiny 'with';
27 with 'RoleA', 'RoleB';
28 }, undef, 'Composing multiple roles which use the same role should not have conflicts' );
29 sub new { bless {} => shift }
31 my $object = Foo->new;
32 foreach my $method (qw/foo bar baz/) {
33 ::can_ok $object, $method;
34 ::is $object->$method, $method,
35 '... and all methods should be composed in correctly';
40 no warnings 'redefine';
41 local *UNIVERSAL::can = sub { 1 };
44 use Role::Tiny 'with';
45 with 'A::NonExistent::Role';
48 like $error, qr{^Can't locate A/NonExistent/Role.pm},
49 'If ->can always returns true, we should still not think we loaded the role'
50 or diag "Error found: $error";
63 sub new { bless {} => shift }
65 my $object = Frew->new;
67 ::ok(!Role::Tiny::does_role($object, 'Role1'), 'no Role1 yet');
68 ::ok(!Role::Tiny::does_role($object, 'Role2'), 'no Role2 yet');
70 Role::Tiny->apply_roles_to_object($object, 'Role1');
71 ::ok(Role::Tiny::does_role($object, "Role1"), 'Role1 consumed');
72 ::ok(!Role::Tiny::does_role($object, 'Role2'), 'no Role2 yet');
73 Role::Tiny->apply_roles_to_object($object, 'Role2');
74 ::ok(Role::Tiny::does_role($object, "Role1"), 'Role1 consumed');
75 ::ok(Role::Tiny::does_role($object, 'Role2'), 'Role2 consumed');