1 use lib 'lib', 't/role-basic/lib', 't/lib';
4 # multiple roles with the same role
23 use Role::Tiny 'with';
25 with 'RoleA', 'RoleB';
26 }, undef, 'Composing multiple roles which use the same role should not have conflicts' );
27 sub new { bless {} => shift }
29 my $object = Foo->new;
30 foreach my $method (qw/foo bar baz/) {
31 ::can_ok $object, $method;
32 ::is $object->$method, $method,
33 '... and all methods should be composed in correctly';
38 no warnings 'redefine';
39 local *UNIVERSAL::can = sub { 1 };
42 use Role::Tiny 'with';
43 with 'A::NonExistent::Role';
49 like $error, qr{^Can't locate A/NonExistent/Role.pm},
50 'If ->can always returns true, we should still not think we loaded the role'
51 or diag "Error found: $error";
64 sub new { bless {} => shift }
66 my $object = Frew->new;
68 ::ok(!Role::Tiny::does_role($object, 'Role1'), 'no Role1 yet');
69 ::ok(!Role::Tiny::does_role($object, 'Role2'), 'no Role2 yet');
71 Role::Tiny->apply_roles_to_object($object, 'Role1');
72 ::ok(Role::Tiny::does_role($object, "Role1"), 'Role1 consumed');
73 ::ok(!Role::Tiny::does_role($object, 'Role2'), 'no Role2 yet');
74 Role::Tiny->apply_roles_to_object($object, 'Role2');
75 ::ok(Role::Tiny::does_role($object, "Role1"), 'Role1 consumed');
76 ::ok(Role::Tiny::does_role($object, 'Role2'), 'Role2 consumed');
79 can_ok(Role::Tiny->create_class_with_roles(qw(Bar Baz))->new, qw(bar baz));