4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
15
my $have_roles = eval { require Role::Tiny };
16
plan skip_all => "Can't load Role::Tiny, not testing Roles"
21
package One::P1; use Lmo::Role;
22
has two => (is => 'ro', default => sub { 'two' });
25
package One::P2; use Lmo::Role;
26
has three => (is => 'ro', default => sub { 'three' });
29
package One::P3; use Lmo::Role;
30
has four => (is => 'ro', default => sub { 'four' });
34
with qw( One::P1 One::P2 );
35
has one => (is => 'ro', default => sub { 'one' });
38
my $combined = One->new();
40
ok $combined->does($_), "Does $_" for qw(One::P1 One::P2);
42
ok !$combined->does($_), "Doesn't $_" for qw(One::P3 One::P4);
44
is $combined->one, "one", "attr default set from class";
45
is $combined->two, "two", "attr default set from role";
46
is $combined->three, "three", "attr default set from role";
51
package Two::P1; use Lmo::Role;
52
has two => (is => 'ro', default => sub { 'two' });
57
has three => ( is => 'ro', default => sub { 'three' } );
66
"unimporting in a role doesn't remove new attributes";
68
for my $class ( qw( Two::P1 Two ) ) {
69
ok !$class->can($_), "...but does remove $_ from $class" for qw(has with extends requires);