| 1 | package With::Roles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | our $VERSION = '0.001002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | my %COMPOSITE_NAME; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | my %COMPOSITE_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | my $role_suffix = 'A000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 18 | ▶ | sub _composite_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_composite_name: called CC=6 SCAR=18.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 18 | my ($base, $role_base, @roles) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 18 | my $key = join('+', $base, map join('|', @$_), @roles); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | return $COMPOSITE_NAME{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 18 | ▶ | if exists $COMPOSITE_NAME{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 16 | my ($cut) = map qr/$_/, join '|', map quotemeta, @$role_base, $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 16 | my $new_name = $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 16 | for my $roles (@roles) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # this creates the potential for ambiguity, but it's unlikely to happen and | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # we will keep the resulting composite | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 18 | my @short_names = @$roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 18 | for (@short_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 19 | s/\A${cut}::/::/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $_ = join '::', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 19 | map { s/\W/_/g; $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | split /::/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 18 | $new_name .= '__WITH__' . join '__AND__', @short_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 16 | ▶ | if ($COMPOSITE_KEY{$new_name} || length($new_name) > 252) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$COMPOSITE_KEY{$new_name} or length $new_name > 252
MC/DC0%0/2
$COMPOSITE_KEY{$new_name} or length $new_name > 252
$COMPOSITE_KEY{$new_name}
length $new_name > 252
Truth table33%1/3
A or B
A= $COMPOSITE_KEY{$new_name}B= length $new_name > 252
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $abbrev = substr $new_name, 0, 250 - length $role_suffix; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $abbrev =~ s/(?<!:):$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $new_name = $abbrev.'__'.$role_suffix++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 16 | $COMPOSITE_KEY{$new_name} = $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 16 | return $COMPOSITE_NAME{$key} = $new_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | ▶ | sub _gen { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 12 | my ($pack, $type, @ops) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 12 | my $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 7 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 84 | local *{"${pack}::${_}"} | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | for qw(with extends requires has around after before); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | ▶ | my $code = join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | "package $pack;\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | (defined $type ? "use $type;\n" : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | map "$ops[$_-1](\@{\$ops[$_]});\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | map $_*2+1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 .. (@ops/2-1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | "1;\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 12 | ▶ | eval $code or $e = $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | ▶ | die $e if defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub _require { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_require: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | (my $module = "$package.pm") =~ s{::|'}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | require $module; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | sub _extends { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extends: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 7 | @{"${caller}::ISA"} = (@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 7 | _copy_mro($_[0], $caller); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 10 | ▶ | sub _copy_mro { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_copy_mro: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 10 | my $source = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 10 | ▶ | my $target = shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table66%2/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 10 | ▶ | mro::set_mro($target, mro::get_mro($source)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | if defined &mro::set_mro; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 12 | ▶ | sub _detect_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detect_type: called CC=23 SCAR=43.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 12 | my ($base, @roles) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 12 | my $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 12 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition100%3/3
$INC{"Moo/Role.pm"} and "Moo::Role"->is_role($base)
MC/DC100%2/2
$INC{"Moo/Role.pm"} and "Moo::Role"->is_role($base)
$INC{"Moo/Role.pm"}
"Moo::Role"->is_role($base)
Truth table100%3/3
A and B
A= $INC{"Moo/Role.pm"}B= "Moo::Role"->is_role($base)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $INC{'Moo/Role.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | and Moo::Role->is_role($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | return 'Moo::Role'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$INC{"Moo.pm"} and "Moo"->_accessor_maker_for($base)
MC/DC50%1/2
$INC{"Moo.pm"} and "Moo"->_accessor_maker_for($base)
$INC{"Moo.pm"}
"Moo"->_accessor_maker_for($base)
Truth table66%2/3
A and B
A= $INC{"Moo.pm"}B= "Moo"->_accessor_maker_for($base)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | $INC{'Moo.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | and Moo->_accessor_maker_for($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | return 'Moo'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$INC{"Class/MOP.pm"} and $meta = Class::MOP::class_of($base) and $meta->isa("Moose::Meta::Role")
$INC{"Class/MOP.pm"} and $meta = Class::MOP::class_of($base)
MC/DC0%0/3
$INC{"Class/MOP.pm"} and $meta = Class::MOP::class_of($base) and $meta->isa("Moose::Meta::Role")
$INC{"Class/MOP.pm"}
$meta = Class::MOP::class_of($base)
$meta->isa("Moose::Meta::Role")
Truth table25%1/4
A and B and C
A= $INC{"Class/MOP.pm"}B= $meta = Class::MOP::class_of($base)C= $meta->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | $INC{'Class/MOP.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | and $meta = Class::MOP::class_of($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | and $meta->isa('Moose::Meta::Role') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return 'Moose::Role'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$INC{"Class/MOP.pm"} and $meta = Class::MOP::class_of($base) and $meta->isa("Class::MOP::Class")
$INC{"Class/MOP.pm"} and $meta = Class::MOP::class_of($base)
MC/DC0%0/3
$INC{"Class/MOP.pm"} and $meta = Class::MOP::class_of($base) and $meta->isa("Class::MOP::Class")
$INC{"Class/MOP.pm"}
$meta = Class::MOP::class_of($base)
$meta->isa("Class::MOP::Class")
Truth table25%1/4
A and B and C
A= $INC{"Class/MOP.pm"}B= $meta = Class::MOP::class_of($base)C= $meta->isa("Class::MOP::Class")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | $INC{'Class/MOP.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | and $meta = Class::MOP::class_of($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | and $meta->isa('Class::MOP::Class') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return 'Moose'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
defined &Mouse::Util::find_meta and $meta = Mouse::Util::find_meta($base) and $meta->isa("Mouse::Meta::Role")
defined &Mouse::Util::find_meta and $meta = Mouse::Util::find_meta($base)
MC/DC0%0/3
defined &Mouse::Util::find_meta and $meta = Mouse::Util::find_meta($base) and $meta->isa("Mouse::Meta::Role")
defined &Mouse::Util::find_meta
$meta = Mouse::Util::find_meta($base)
$meta->isa("Mouse::Meta::Role")
Truth table25%1/4
A and B and C
A= defined &Mouse::Util::find_metaB= $meta = Mouse::Util::find_meta($base)C= $meta->isa("Mouse::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | defined &Mouse::Util::find_meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | and $meta = Mouse::Util::find_meta($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | and $meta->isa('Mouse::Meta::Role') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return 'Mouse::Role'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
defined &Mouse::Util::find_meta and $meta = Mouse::Util::find_meta($base) and $meta->isa("Mouse::Meta::Class")
defined &Mouse::Util::find_meta and $meta = Mouse::Util::find_meta($base)
MC/DC0%0/3
defined &Mouse::Util::find_meta and $meta = Mouse::Util::find_meta($base) and $meta->isa("Mouse::Meta::Class")
defined &Mouse::Util::find_meta
$meta = Mouse::Util::find_meta($base)
$meta->isa("Mouse::Meta::Class")
Truth table25%1/4
A and B and C
A= defined &Mouse::Util::find_metaB= $meta = Mouse::Util::find_meta($base)C= $meta->isa("Mouse::Meta::Class")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | defined &Mouse::Util::find_meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | and $meta = Mouse::Util::find_meta($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | and $meta->isa('Mouse::Meta::Class') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return 'Mouse'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($base)
MC/DC50%1/2
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($base)
$INC{"Role/Tiny.pm"}
"Role::Tiny"->is_role($base)
Truth table66%2/3
A and B
A= $INC{"Role/Tiny.pm"}B= "Role::Tiny"->is_role($base)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $INC{'Role/Tiny.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | and Role::Tiny->is_role($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | return 'Role::Tiny'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | eval { _require($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 7 | ▶ | for grep !($INC{'Role/Tiny.pm'} && Role::Tiny->is_role($_)), @roles; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$INC{'Role/Tiny.pm'} && 'Role::Tiny'->is_role($_)
MC/DC0%0/2
$INC{'Role/Tiny.pm'} && 'Role::Tiny'->is_role($_)
$INC{'Role/Tiny.pm'}
'Role::Tiny'->is_role($_)
Truth table33%1/3
A && B
A= $INC{'Role/Tiny.pm'}B= 'Role::Tiny'->is_role($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$INC{"Role/Tiny.pm"} and not grep((!"Role::Tiny"->is_role($_)), @roles)
MC/DC0%0/2
$INC{"Role/Tiny.pm"} and not grep((!"Role::Tiny"->is_role($_)), @roles)
$INC{"Role/Tiny.pm"}
not grep((!"Role::Tiny"->is_role($_)), @roles)
Truth table33%1/3
A and not(B)
A= $INC{"Role/Tiny.pm"}B= not grep((!"Role::Tiny"->is_role($_)), @roles)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $INC{'Role/Tiny.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | and !grep !Role::Tiny->is_role($_), @roles | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | return 'Role::Tiny::With'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 7 | my %BASE; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 14 | ▶ | sub with::roles { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
roles: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 14 | my ($self, @roles) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 14 | ▶ | return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | if !@roles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 14 | ▶ | my $base = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table66%2/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 14 | ▶ | my ($orig_base, @base_roles) = @{ $BASE{$base} || [$base] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$BASE{$base} || [$base]
MC/DC100%1/1
$BASE{$base} || [$base]
$BASE{$base}
Truth table100%2/2
A
A= $BASE{$base}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 14 | ▶ | my $role_base = $self->can('ROLE_BASE') ? $self->ROLE_BASE : $orig_base.'::Role'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 14 | s/\A\+/${role_base}::/ for @roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 14 | my @all_roles = (@base_roles, [ @roles ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 14 | my $new = _composite_name($orig_base, [ $role_base ], @all_roles); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 14 | ▶ | if (!exists $BASE{$new}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 12 | ▶ | my $type = _detect_type($base, @roles) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | or croak "Can't determine class or role type of $base or @roles!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 12 | my @ops; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 12 | ▶ | if ($type eq 'Role::Tiny::With') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 7 | push @ops, __PACKAGE__.'::_extends', [ $base ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif ($type =~ /Role/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | push @ops, with => [ $base ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | push @ops, extends => [ $base ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | push @ops, __PACKAGE__.'::_copy_mro' => [ $base ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 12 | push @ops, with => [ @roles ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 12 | _gen($new, $type, @ops); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 14 | $BASE{$new} = [$orig_base, @all_roles]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | ▶ | if (ref $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # using $_[0] rather than $self, to work around how overload magic is | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # applied on perl 5.8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | return bless $_[0], $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 12 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||