| 1 | package Kelp::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # No Kelp::Base here, because Kelp::Base uses Kelp::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 58 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 58 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 58 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 58 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 58 | ▶ | use Data::Dumper qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 58 | ▶ | use Encode qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 58 | ▶ | use Class::Inspector; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 58 | ▶ | use Plack::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 58 | ▶ | use Test::Deep::NoTest qw(eq_deeply); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 58 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # improve error locations of croak | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 58 | our @CARP_NOT = ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 19 | Kelp | ||||||||||||||||||||||||||||||||||||||||||
| 20 | Kelp::Base | ||||||||||||||||||||||||||||||||||||||||||
| 21 | Kelp::Routes | ||||||||||||||||||||||||||||||||||||||||||
| 22 | Kelp::Context | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub _DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 947 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_DEBUG: called CC=4 SCAR=23.3
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 947 | my ($stage, @messages) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 947 | my $env = $ENV{KELP_DEBUG}; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 947 | ▶ | return if !$env; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return if !grep { lc $env eq $_ } '1', 'all', lc $stage; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | my $message = join ' ', map { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | ref $_ ? Data::Dumper::Dumper($_) : $_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } @messages; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | print "DEBUG: $message\n"; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | sub camelize | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 202 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
camelize: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 202 | my ($string, $base, $class_only) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 202 | ▶ | return $string unless $string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 198 | ▶ | my $sigil = defined $string && $string =~ s/^(\+)// ? $1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $string and $string =~ s/^(\+)//
MC/DC50%1/2
defined $string and $string =~ s/^(\+)//
defined $string
$string =~ s/^(\+)//
Truth table66%2/3
A and B
A= defined $stringB= $string =~ s/^(\+)//
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 198 | ▶ | $base = undef if $sigil; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 198 | my @parts; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 198 | ▶ | if ($string !~ /#/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | # do not camelize if it doesn't look like a camelize string | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 71 | @parts = ($string); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 127 | @parts = split /\#/, $string; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 127 | my $sub = pop @parts; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 127 | ▶ | push @parts, $sub | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | if $class_only; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | @parts = map { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 127 | join '', map { ucfirst lc } split /\_/ | |||||||||||||||||||||||||||||||||||||||||
| 64 | } @parts; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 127 | ▶ | push @parts, $sub | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | if !$class_only; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 198 | ▶ | unshift @parts, $base if $base; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 198 | return join('::', @parts); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | sub extract_class | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 128 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_class: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 128 | my ($string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 128 | ▶ | return undef unless $string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 127 | ▶ | if ($string =~ /^(.+)::(\w+)$/ && $1 ne 'main') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$string =~ /^(.+)::(\w+)$/ and $1 ne "main"
MC/DC100%2/2
$string =~ /^(.+)::(\w+)$/ and $1 ne "main"
$string =~ /^(.+)::(\w+)$/
$1 ne "main"
Truth table100%3/3
A and B
A= $string =~ /^(.+)::(\w+)$/B= $1 ne "main"
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 109 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 18 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | sub extract_function | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 108 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_function: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 108 | my ($string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 108 | ▶ | return undef unless $string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 107 | ▶ | if ($string =~ /^(.+)::(\w+)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 106 | return $2; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | sub effective_charset | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 308 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
effective_charset: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 308 | my $this_charset = shift; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 308 | ▶ | return Encode::find_encoding($this_charset) ? $this_charset : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | sub charset_encode | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 246 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
charset_encode: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 246 | my ($charset, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 246 | ▶ | return $string unless $charset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 245 | return Encode::encode $charset, $string; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | sub charset_decode | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 628 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
charset_decode: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 628 | my ($charset, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 628 | ▶ | return $string unless $charset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 627 | return Encode::decode $charset, $string; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | sub adapt_psgi | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adapt_psgi: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | my ($app) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | ▶ | croak 'Cannot adapt_psgi, unknown destination type - must be a coderef' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | unless ref $app eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 11 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | my $context = shift->context; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 11 | ▶ | my $path = charset_encode($context->app->request_charset, pop() // ''); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
pop() // ""
MC/DC100%1/1
pop() // ""
pop()
Truth table100%2/2
A
A= pop()
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 11 | my $env = $context->req->env; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | # remember script and path | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 11 | my $orig_script = $env->{SCRIPT_NAME}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 11 | my $orig_path = $env->{PATH_INFO}; | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | # adjust slashes in paths | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 11 | ▶ | my $trailing_slash = $orig_path =~ m{/$} ? '/' : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 11 | $path =~ s{^/?}{/}; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 11 | $path =~ s{/?$}{$trailing_slash}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 11 | my $result = do { | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # adjust script and path | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 11 | local $env->{SCRIPT_NAME} = $orig_path; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 11 | $env->{SCRIPT_NAME} =~ s{\Q$path\E$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 11 | local $env->{PATH_INFO} = $path; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | # run the callback | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 11 | $app->($env); | |||||||||||||||||||||||||||||||||||||||||
| 150 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | # produce a response | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 11 | ▶ | if (ref $result eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 11 | my ($status, $headers, $body) = @{$result}; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | my $res = $context->res; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 11 | ▶ | $res->status($status) if $status; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | ▶ | $res->headers($headers) if $headers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 11 | ▶ | $res->body($body) if $body; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 11 | $res->rendered(1); | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | elsif (ref $result eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | # this should be an error unless already rendered | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 11 | return; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | sub load_package | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1825 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_package: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 1825 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 1825 | state $loaded = {}; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | # only load package once for a given class name | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 1825 | ▶ | return $loaded->{$package} //= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$loaded->{$package} //= do {
Plack::Util::load_class($package) unless "Class::Inspector"->loaded($package);
$package
}
MC/DC100%2/2
$loaded->{$package} //= do {
Plack::Util::load_class($package) unless "Class::Inspector"->loaded($package);
$package
}
$loaded->{$package}
do {
Plack::Util::load_class($package) unless "Class::Inspector"->loaded($package);
$package
}
Truth table100%3/3
A //= B
A= $loaded->{$package}B= do {
Plack::Util::load_class($package) unless "Class::Inspector"->loaded($package);
$package
}
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 388 | ▶ | Plack::Util::load_class($package) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | unless Class::Inspector->loaded($package); | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 385 | $package; | |||||||||||||||||||||||||||||||||||||||||
| 181 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | sub merge | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 166 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=15 SCAR=27.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 166 | my ($a, $b, $allow_blessed, $sigil) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my $ref = $allow_blessed ? sub { reftype $_[0] // '' } : sub { ref $_[0] }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=10.1
Subroutine
__ANON__: called CC=1 SCAR=1.7
Branch: 1 branch
Condition0%0/2
builtin::reftype($_[0]) // ""
MC/DC0%0/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table0%0/2
A
A= builtin::reftype($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 166 | ▶ | return $b | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not &$ref($a) && &$ref($b) or &$ref($a) ne &$ref($b)
&$ref($a) && &$ref($b)
MC/DC66%2/3
not &$ref($a) && &$ref($b) or &$ref($a) ne &$ref($b)
&$ref($a)
&$ref($b)
&$ref($a) ne &$ref($b)
Truth table75%3/4
not(A && B) or C
A= &$ref($a)B= &$ref($b)C= &$ref($a) ne &$ref($b)
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | if !$ref->($a) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | || !$ref->($b) | ||||||||||||||||||||||||||||||||||||||||||
| 192 | || $ref->($a) ne $ref->($b); | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 149 | ▶ | if ($ref->($a) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 47 | ▶ | return $b unless $sigil; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 36 | ▶ | if ($sigil eq '+') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | for my $e (@$b) { | |||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | ▶ | push @$a, $e unless grep { eq_deeply($_, $e) } @$a; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | $a = [ | ||||||||||||||||||||||||||||||||||||||||||
| 203 | grep { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 31 | my $e = $_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 63 | !grep { eq_deeply($_, $e) } @$b | |||||||||||||||||||||||||||||||||||||||||
| 206 | } @$a | ||||||||||||||||||||||||||||||||||||||||||
| 207 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 36 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | elsif ($ref->($a) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 102 | for my $k (keys %$b) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | # If the key is an array then look for a merge sigil | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 113 | ▶ | my $s = $ref->($b->{$k}) eq 'ARRAY' && $k =~ s/^(\+|\-)// ? $1 : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&$ref($b->{$k}) eq "ARRAY" and $k =~ s/^(\+|\-)//
MC/DC100%2/2
&$ref($b->{$k}) eq "ARRAY" and $k =~ s/^(\+|\-)//
&$ref($b->{$k}) eq "ARRAY"
$k =~ s/^(\+|\-)//
Truth table100%3/3
A and B
A= &$ref($b->{$k}) eq "ARRAY"B= $k =~ s/^(\+|\-)//
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | $a->{$k} = | ||||||||||||||||||||||||||||||||||||||||||
| 218 | exists $a->{$k} | ||||||||||||||||||||||||||||||||||||||||||
| 219 | ? merge($a->{$k}, $b->{"$s$k"}, $allow_blessed, $s) | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 113 | ▶ | : $b->{$k}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 102 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $b; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 58 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | __END__ | ||||||||||||||||||||||||||||||||||||||||||