| 1 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Version::Requirements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | $Version::Requirements::VERSION = '0.101022'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ABSTRACT: a set of version requirements for a CPAN dist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use version 0.77 (); # the ->parse method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # We silence this warning during core tests, because this is only in core | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # because it has to be, and nobody wants to see this stupid warning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # -- rjbs, 2012-01-20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | Carp::cluck( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | "Version::Requirements is deprecated; replace with CPAN::Meta::Requirements" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | ) unless $ENV{PERL_CORE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 31 | ▶ | my ($class) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 31 | return bless {} => $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub _version_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 106 | ▶ | my ($self, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_version_object: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 106 | ▶ | $version = (! defined $version) ? version->parse(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | : (! Scalar::Util::blessed($version)) ? version->parse($version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | : $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 106 | return $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | ▶ | for my $type (qw(minimum maximum exclusion exact_version)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 20 | my $method = "with_$type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 20 | ▶ | my $to_add = $type eq 'exact_version' ? $type : "add_$type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | my $code = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 100 | ▶ | my ($self, $name, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 100 | $version = $self->_version_object( $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 100 | $self->__modify_entry_for($name, $method, $version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 90 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 20 | *$to_add = $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | sub add_requirements { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | ▶ | my ($self, $req) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_requirements: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | for my $module ($req->required_modules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 14 | my $modifiers = $req->__entry_for($module)->as_modifiers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 14 | for my $modifier (@$modifiers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 17 | my ($method, @args) = @$modifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 17 | $self->$method($module => @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | sub accepts_module { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | ▶ | my ($self, $module, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accepts_module: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 6 | $version = $self->_version_object( $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | ▶ | return 1 unless my $range = $self->__entry_for($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | return $range->_accepts($version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub clear_requirement { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | my ($self, $module) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_requirement: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | return $self unless $self->__entry_for($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | ▶ | Carp::confess("can't clear requirements on finalized requirements") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | if $self->is_finalized; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | delete $self->{requirements}{ $module }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 31 | ▶ | sub required_modules { keys %{ $_[0]{requirements} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
required_modules: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | my $new = (ref $self)->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | return $new->add_requirements($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 127 | ▶ | sub __entry_for { $_[0]{requirements}{ $_[1] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__entry_for: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | sub __modify_entry_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 100 | ▶ | my ($self, $name, $method, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__modify_entry_for: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 100 | my $fin = $self->is_finalized; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 100 | my $old = $self->__entry_for($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 100 | ▶ | Carp::confess("can't add new requirements to finalized requirements") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$fin and not $old
MC/DC100%2/2
$fin and not $old
$fin
not $old
Truth table100%3/3
A and not(B)
A= $finB= not $old
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | if $fin and not $old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 99 | ▶ | my $new = ($old || 'Version::Requirements::_Range::Range') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$old || 'Version::Requirements::_Range::Range'
MC/DC100%1/1
$old || 'Version::Requirements::_Range::Range'
$old
Truth table100%2/2
A
A= $old
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ->$method($version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 91 | ▶ | Carp::confess("can't modify finalized requirements") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$fin and $old->as_string ne $new->as_string
MC/DC100%2/2
$fin and $old->as_string ne $new->as_string
$fin
$old->as_string ne $new->as_string
Truth table100%3/3
A and B
A= $finB= $old->as_string ne $new->as_string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | if $fin and $old->as_string ne $new->as_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 90 | $self->{requirements}{ $name } = $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | sub is_simple { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_simple: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | for my $module ($self->required_modules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # XXX: This is a complete hack, but also entirely correct. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | ▶ | return if $self->__entry_for($module)->as_string =~ /\s/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 102 | ▶ | sub is_finalized { $_[0]{finalized} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_finalized: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | sub finalize { $_[0]{finalized} = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | sub as_string_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 23 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 23 | my %hash = map {; $_ => $self->{requirements}{$_}->as_string } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | $self->required_modules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 23 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | my %methods_for_op = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | '==' => [ qw(exact_version) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | '!=' => [ qw(add_exclusion) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | '>=' => [ qw(add_minimum) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | '<=' => [ qw(add_maximum) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | '>' => [ qw(add_minimum add_exclusion) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | '<' => [ qw(add_maximum add_exclusion) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sub from_string_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | my ($class, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_string_hash: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | my $self = $class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | for my $module (keys %$hash) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | my @parts = split qr{\s*,\s*}, $hash->{ $module }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | for my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 7 | my ($op, $ver) = split /\s+/, $part, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 7 | ▶ | if (! defined $ver) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | $self->add_minimum($module => $op); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | Carp::confess("illegal requirement string: $hash->{ $module }") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | ▶ | unless my $methods = $methods_for_op{ $op }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | $self->$_($module => $ver) for @$methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | Version::Requirements::_Range::Exact; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 16 | ▶ | sub _new { bless { version => $_[1] } => $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | sub _accepts { return $_[0]{version} == $_[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accepts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 6 | ▶ | sub as_string { return "== $_[0]{version}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | sub as_modifiers { return [ [ exact_version => $_[0]{version} ] ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_modifiers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sub _clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | ▶ | (ref $_[0])->_new( version->new( $_[0]{version} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clone: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | sub with_exact_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | my ($self, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_exact_version: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | return $self->_clone if $self->_accepts($version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | Carp::confess("illegal requirements: unequal exact version specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub with_minimum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | ▶ | my ($self, $minimum) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_minimum: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | ▶ | return $self->_clone if $self->{version} >= $minimum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | Carp::confess("illegal requirements: minimum above exact specification"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | sub with_maximum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | ▶ | my ($self, $maximum) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_maximum: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | ▶ | return $self->_clone if $self->{version} <= $maximum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | Carp::confess("illegal requirements: maximum below exact specification"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | sub with_exclusion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | ▶ | my ($self, $exclusion) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_exclusion: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3 | ▶ | return $self->_clone unless $exclusion == $self->{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | Carp::confess("illegal requirements: excluded exact specification"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Version::Requirements::_Range::Range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub _self { ref($_[0]) ? $_[0] : (bless { } => $_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_self: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub _clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 87 | ▶ | return (bless { } => $_[0]) unless ref $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clone: called CC=5 SCAR=16.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 36 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | my %guts = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | (exists $s->{minimum} ? (minimum => version->new($s->{minimum})) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | (exists $s->{maximum} ? (maximum => version->new($s->{maximum})) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | (exists $s->{exclusions} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 36 | ▶ | ? (exclusions => [ map { version->new($_) } @{ $s->{exclusions} } ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 36 | bless \%guts => ref($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | sub as_modifiers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 12 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_modifiers: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 12 | my @mods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 12 | ▶ | push @mods, [ add_minimum => $self->{minimum} ] if exists $self->{minimum}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 12 | ▶ | push @mods, [ add_maximum => $self->{maximum} ] if exists $self->{maximum}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 12 | ▶ | push @mods, map {; [ add_exclusion => $_ ] } @{$self->{exclusions} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 12 | return \@mods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 49 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 49 | ▶ | return 0 if ! keys %$self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 49 | ▶ | return "$self->{minimum}" if (keys %$self) == 1 and exists $self->{minimum}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
keys %$self == 1 and exists $self->{"minimum"}
MC/DC100%2/2
keys %$self == 1 and exists $self->{"minimum"}
keys %$self == 1
exists $self->{"minimum"}
Truth table100%3/3
A and B
A= keys %$self == 1B= exists $self->{"minimum"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 15 | ▶ | my @exclusions = @{ $self->{exclusions} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 15 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 15 | for my $pair ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | [ qw( >= > minimum ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | [ qw( <= < maximum ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 30 | my ($op, $e_op, $k) = @$pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 30 | ▶ | if (exists $self->{$k}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 24 | my @new_exclusions = grep { $_ != $self->{ $k } } @exclusions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 24 | ▶ | if (@new_exclusions == @exclusions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 23 | push @parts, "$op $self->{ $k }"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | push @parts, "$e_op $self->{ $k }"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | @exclusions = @new_exclusions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 15 | push @parts, map {; "!= $_" } @exclusions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 15 | return join q{, }, @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub with_exact_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | ▶ | my ($self, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_exact_version: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | $self = $self->_clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | ▶ | Carp::confess("illegal requirements: exact specification outside of range") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | unless $self->_accepts($version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 7 | return Version::Requirements::_Range::Exact->_new($version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | sub _simplify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 79 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_simplify: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 79 | ▶ | if (defined $self->{minimum} and defined $self->{maximum}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"minimum"} and defined $self->{"maximum"}
MC/DC100%2/2
defined $self->{"minimum"} and defined $self->{"maximum"}
defined $self->{"minimum"}
defined $self->{"maximum"}
Truth table100%3/3
A and B
A= defined $self->{"minimum"}B= defined $self->{"maximum"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 19 | ▶ | if ($self->{minimum} == $self->{maximum}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | Carp::confess("illegal requirements: excluded all values") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | ▶ | if grep { $_ == $self->{minimum} } @{ $self->{exclusions} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | return Version::Requirements::_Range::Exact->_new($self->{minimum}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | Carp::confess("illegal requirements: minimum exceeds maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 17 | ▶ | if $self->{minimum} > $self->{maximum}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # eliminate irrelevant exclusions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 75 | ▶ | if ($self->{exclusions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 21 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 21 | @{ $self->{exclusions} } = grep { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | (! defined $self->{minimum} or $_ >= $self->{minimum}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | (! defined $self->{maximum} or $_ <= $self->{maximum}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 22 | ▶ | ! $seen{$_}++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
!defined($self->{"minimum"}) || $_ >= $self->{"minimum"} and !defined($self->{"maximum"}) || $_ <= $self->{"maximum"}
not defined $self->{"minimum"} or $_ >= $self->{"minimum"}
not defined $self->{"maximum"} or $_ <= $self->{"maximum"}
MC/DC0%0/4
!defined($self->{"minimum"}) || $_ >= $self->{"minimum"} and !defined($self->{"maximum"}) || $_ <= $self->{"maximum"}
not defined $self->{"minimum"}
$_ >= $self->{"minimum"}
not defined $self->{"maximum"}
$_ <= $self->{"maximum"}
Truth table0%0/7
not(A) or B and not(C) or D
A= not defined $self->{"minimum"}B= $_ >= $self->{"minimum"}C= not defined $self->{"maximum"}D= $_ <= $self->{"maximum"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 21 | } @{ $self->{exclusions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 75 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | sub with_minimum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 48 | ▶ | my ($self, $minimum) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_minimum: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 48 | $self = $self->_clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 48 | ▶ | if (defined (my $old_min = $self->{minimum})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 10 | $self->{minimum} = (sort { $b cmp $a } ($minimum, $old_min))[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 38 | $self->{minimum} = $minimum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 48 | return $self->_simplify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | sub with_maximum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 17 | ▶ | my ($self, $maximum) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_maximum: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 17 | $self = $self->_clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 17 | ▶ | if (defined (my $old_max = $self->{maximum})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | $self->{maximum} = (sort { $a cmp $b } ($maximum, $old_max))[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 16 | $self->{maximum} = $maximum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 17 | return $self->_simplify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | sub with_exclusion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 14 | ▶ | my ($self, $exclusion) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_exclusion: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 14 | $self = $self->_clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 14 | ▶ | push @{ $self->{exclusions} ||= [] }, $exclusion; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"exclusions"} ||= []
MC/DC100%1/1
$self->{"exclusions"} ||= []
$self->{"exclusions"}
Truth table100%2/2
A
A= $self->{"exclusions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 14 | return $self->_simplify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | sub _accepts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 14 | ▶ | my ($self, $version) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accepts: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 14 | ▶ | return if defined $self->{minimum} and $version < $self->{minimum}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"minimum"} and $version < $self->{"minimum"}
MC/DC100%2/2
defined $self->{"minimum"} and $version < $self->{"minimum"}
defined $self->{"minimum"}
$version < $self->{"minimum"}
Truth table100%3/3
A and B
A= defined $self->{"minimum"}B= $version < $self->{"minimum"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 12 | ▶ | return if defined $self->{maximum} and $version > $self->{maximum}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"maximum"} and $version > $self->{"maximum"}
MC/DC100%2/2
defined $self->{"maximum"} and $version > $self->{"maximum"}
defined $self->{"maximum"}
$version > $self->{"maximum"}
Truth table100%3/3
A and B
A= defined $self->{"maximum"}B= $version > $self->{"maximum"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | return if defined $self->{exclusions} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 11 | ▶ | and grep { $version == $_ } @{ $self->{exclusions} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"exclusions"} and grep {$version == $_;} @{$$self{"exclusions"};}
MC/DC100%2/2
defined $self->{"exclusions"} and grep {$version == $_;} @{$$self{"exclusions"};}
defined $self->{"exclusions"}
grep {$version == $_;} @{$$self{"exclusions"};}
Truth table100%3/3
A and B
A= defined $self->{"exclusions"}B= grep {$version == $_;} @{$$self{"exclusions"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 10 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||