| 1 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Data::ZPath::_Evaluate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use POSIX qw(ceil floor); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Regexp::Util qw(deserialize_regexp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Scalar::Util qw(blessed refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Data::ZPath::Node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | our $VERSION = '0.001000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | ▶ | sub _pattern_to_regexp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pattern_to_regexp: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | my ( $pat ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | for my $candidate ( qw{ / | : " ' }, '#' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | ▶ | if ( index($pat, $candidate) < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 14 | return deserialize_regexp sprintf( 'qr%s%s%s', $candidate, $pat, $candidate ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $pat =~ s{\/}{\\\/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return deserialize_regexp sprintf( 'qr/%s/', $pat ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2800 | ▶ | sub _eval_expr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval_expr: called CC=65 SCAR=45.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2800 | my ( $ast, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2800 | my $t = $ast->{t}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2800 | ▶ | if ( $t eq 'num' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 254 | return Data::ZPath::Node->_wrap($ast->{v}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2546 | ▶ | if ( $t eq 'str' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 550 | return Data::ZPath::Node->_wrap($ast->{v}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1996 | ▶ | if ( $t eq 'path' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 906 | return _eval_path($ast, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1090 | ▶ | if ( $t eq 'fn' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 374 | return _eval_fn($ast, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 716 | ▶ | if ( $t eq 'un' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 13 | my @v = _eval_expr($ast->{e}, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 13 | my $x = _truthy($v[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | ▶ | if ( $ast->{op} eq '!' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | ▶ | return (Data::ZPath::Node->_wrap($x ? !!0 : !!1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | if ( $ast->{op} eq '~' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $n = _to_number($v[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | return unless defined $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | return Data::ZPath::Node->_wrap((~(int($n)))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | croak "Unknown unary op $ast->{op}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 703 | ▶ | if ( $t eq 'bin' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 696 | my @l = _eval_expr($ast->{l}, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 696 | my @r = _eval_expr($ast->{r}, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 696 | my $lv = $l[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 696 | my $rv = $r[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 696 | my $op = $ast->{op}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # Logical ops treat as booleans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 696 | ▶ | if ( $op eq '&&' || $op eq '||' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "&&" or $op eq "||"
MC/DC100%2/2
$op eq "&&" or $op eq "||"
$op eq "&&"
$op eq "||"
Truth table100%3/3
A or B
A= $op eq "&&"B= $op eq "||"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 22 | my $lb = _truthy($lv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 22 | my $rb = _truthy($rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 22 | ▶ | return (Data::ZPath::Node->_wrap( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$lb and $rb
$lb or $rb
MC/DC100%2/2
$lb and $rb
$lb
$rb
MC/DC100%2/2
$lb or $rb
$lb
$rb
Truth table100%3/3
A and B
A= $lbB= $rb
Truth table100%3/3
A or B
A= $lbB= $rb
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ($op eq '&&') ? ($lb && $rb ? !!1 : !!0) : ($lb || $rb ? !!1 : !!0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | undef, undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Equality (loose-ish, but stable) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 674 | ▶ | if ( $op eq '==' || $op eq '!=' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "==" or $op eq "!="
MC/DC100%2/2
$op eq "==" or $op eq "!="
$op eq "=="
$op eq "!="
Truth table100%3/3
A or B
A= $op eq "=="B= $op eq "!="
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 628 | my $eq = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 628 | ▶ | if ( @l && @r ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@l and @r
MC/DC50%1/2
@l and @r
@l
@r
Truth table66%2/3
A and B
A= @lB= @r
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | OUTER: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 227 | for my $ln (@l) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 228 | for my $rn (@r) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 228 | ▶ | if ( _equals($ln, $rn) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 78 | $eq = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 78 | last OUTER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 628 | ▶ | $eq = !$eq if $op eq '!='; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 628 | ▶ | return (Data::ZPath::Node->_wrap($eq ? !!1 : !!0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # Relations (numeric if both numeric, else string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 46 | ▶ | if ( $op =~ /^( >= | <= | > | < )$/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | my $ln = _to_number($lv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | my $rn = _to_number($rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | my $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | ▶ | if ( defined $ln && defined $rn ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ln and defined $rn
MC/DC0%0/2
defined $ln and defined $rn
defined $ln
defined $rn
Truth table33%1/3
A and B
A= defined $lnB= defined $rn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | ▶ | $ok = ($op eq '>=' ? $ln >= $rn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | : $op eq '<=' ? $ln <= $rn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | : $op eq '>' ? $ln > $rn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | : $ln < $rn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my $ls = _to_string($lv) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_to_string($lv) // ""
MC/DC0%0/1
_to_string($lv) // ""
_to_string($lv)
Truth table0%0/2
A
A= _to_string($lv)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $rs = _to_string($rv) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_to_string($rv) // ""
MC/DC0%0/1
_to_string($rv) // ""
_to_string($rv)
Truth table0%0/2
A
A= _to_string($rv)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $ok = ($op eq '>=' ? $ls ge $rs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | : $op eq '<=' ? $ls le $rs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | : $op eq '>' ? $ls gt $rs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | : $ls lt $rs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | return (Data::ZPath::Node->_wrap($ok ? !!1 : !!0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # Bitwise ops (ints) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 43 | ▶ | if ( $op eq '&' || $op eq '|' || $op eq '^' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$op eq "&" or $op eq "|" or $op eq "^"
$op eq "&" or $op eq "|"
MC/DC100%3/3
$op eq "&" or $op eq "|" or $op eq "^"
$op eq "&"
$op eq "|"
$op eq "^"
Truth table100%4/4
A or B or C
A= $op eq "&"B= $op eq "|"C= $op eq "^"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | my $ln = _to_number($lv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | my $rn = _to_number($rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | return () unless defined $ln && defined $rn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ln and defined $rn
MC/DC0%0/2
defined $ln and defined $rn
defined $ln
defined $rn
Truth table33%1/3
A and B
A= defined $lnB= defined $rn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | my $li = int($ln); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | my $ri = int($rn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | my $res = ($op eq '&') ? ($li & $ri) : ($op eq '|') ? ($li | $ri) : ($li ^ $ri); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | return (Data::ZPath::Node->_wrap($res)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # Arithmetic (scalar only) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 39 | ▶ | if ( $op eq '+' || $op eq '-' || $op eq '*' || $op eq '/' || $op eq '%' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition91%11/12
$op eq "+" or $op eq "-" or $op eq "*" or $op eq "/" or $op eq "%"
$op eq "+" or $op eq "-" or $op eq "*" or $op eq "/"
$op eq "+" or $op eq "-" or $op eq "*"
$op eq "+" or $op eq "-"
MC/DC0%0/5
$op eq "+" or $op eq "-" or $op eq "*" or $op eq "/" or $op eq "%"
$op eq "+"
$op eq "-"
$op eq "*"
$op eq "/"
$op eq "%"
Truth table83%5/6
A or B or C or D or E
A= $op eq "+"B= $op eq "-"C= $op eq "*"D= $op eq "/"E= $op eq "%"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 39 | my $ln = _to_number($lv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 39 | my $rn = _to_number($rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 39 | ▶ | if ( $op eq '%' and $ln=~/\./ || $rn=~/\./ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$op eq "%" and $ln =~ /\./ || $rn =~ /\./
$ln =~ /\./ or $rn =~ /\./
MC/DC66%2/3
$op eq "%" and $ln =~ /\./ || $rn =~ /\./
$op eq "%"
$ln =~ /\./
$rn =~ /\./
Truth table75%3/4
A and B or C
A= $op eq "%"B= $ln =~ /\./C= $rn =~ /\./
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | return Data::ZPath::Node->_wrap(_floaty_modulus($ln, $rn)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 36 | ▶ | return () unless defined $ln && defined $rn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ln and defined $rn
MC/DC0%0/2
defined $ln and defined $rn
defined $ln
defined $rn
Truth table33%1/3
A and B
A= defined $lnB= defined $rn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 36 | ▶ | my $res = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $op eq '+' ? ($ln + $rn) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | $op eq '-' ? ($ln - $rn) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | $op eq '*' ? ($ln * $rn) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | $op eq '/' ? ($rn == 0 ? undef : ($ln / $rn)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ($rn == 0 ? undef : ($ln % $rn)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 36 | ▶ | return unless defined $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 36 | return Data::ZPath::Node->_wrap($res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | croak "Unknown binary op $op"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | ▶ | if ( $t eq 'ternary' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | my @c = _eval_expr($ast->{c}, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 7 | my $cond = _truthy($c[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 7 | ▶ | return $cond ? _eval_expr($ast->{a}, $ctx) : _eval_expr($ast->{b}, $ctx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | croak "Unknown AST node type: $t"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Reference implementation of ZPath is in Java, which has a sane | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # floating point modulus opertator. Try to implement equivalent in Perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | sub _floaty_modulus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_floaty_modulus: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my ( $ln, $rn ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | my $count = POSIX::floor($ln / $rn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | $ln - ( $count * $rn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 906 | ▶ | sub _eval_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval_path: called CC=48 SCAR=38.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 906 | my ( $path_ast, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 906 | my @current = @{$ctx->nodeset}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 906 | my $parentset = $ctx->parentset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 906 | for my $seg (@{$path_ast->{s}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1308 | my @next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1308 | ▶ | if ( $seg->{k} eq 'root' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 133 | @next = ($ctx->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif ( $seg->{k} eq 'dot' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 24 | @next = @current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif ( $seg->{k} eq 'parent' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 13 | @next = grep { defined $_ } map { $_->parent } @current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 13 | @next = _dedup_nodes(@next); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | elsif ( $seg->{k} eq 'ancestors' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | my @anc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | my $p = $n->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | ▶ | while ( $p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | push @anc, $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | $p = $p->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | @next = _dedup_nodes(@anc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | elsif ( $seg->{k} eq 'star' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 93 | my @kids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 93 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 93 | push @kids, grep { $_->type ne 'attr' } $n->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 93 | @next = _dedup_nodes(@kids); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | elsif ( $seg->{k} eq 'desc' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 85 | my @acc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 85 | my @stack = @current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 85 | ▶ | while ( @stack ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3259 | my $n = shift @stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 3259 | push @acc, $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3259 | my @kids = grep { $_->type ne 'attr' } $n->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 3259 | push @stack, @kids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 85 | @next = _dedup_nodes(@acc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | elsif ( $seg->{k} eq 'index' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 28 | my $idx = $seg->{i}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 28 | my @kids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 28 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 28 | my @ch = grep { $_->type ne 'attr' } $n->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 28 | ▶ | push @kids, $ch[$idx] if defined $ch[$idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 28 | @next = _dedup_nodes(@kids); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | elsif ( $seg->{k} eq 'fnseg' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 7 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 16 | my $seg_ctx = $ctx->with_nodeset( [$n], \@current ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 16 | my @res = _eval_fn({ t => 'fn', n => $seg->{n}, a => $seg->{a} }, $seg_ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 16 | push @out, @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 7 | @next = @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | elsif ( $seg->{k} eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 923 | my $name = $seg->{n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # XML attribute shorthand: @name or @* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 923 | ▶ | if ( $name =~ /^\@/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 158 | ▶ | if ( $name eq '@*' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | my @attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | for my $n (@current) { push @attrs, $n->attributes; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 3 | @next = _dedup_nodes(@attrs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 155 | my $attr_name = substr($name, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 155 | my @attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 155 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 160 | my $raw = $n->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 160 | ▶ | next unless blessed($raw) && $raw->isa('XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($raw) and $raw->isa("XML::LibXML::Element")
MC/DC50%1/2
builtin::blessed($raw) and $raw->isa("XML::LibXML::Element")
builtin::blessed($raw)
$raw->isa("XML::LibXML::Element")
Truth table66%2/3
A and B
A= builtin::blessed($raw)B= $raw->isa("XML::LibXML::Element")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 106 | my $a = $raw->getAttributeNode($attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 106 | ▶ | push @attrs, Data::ZPath::Node->_wrap($a, $n, '@'.$attr_name) if $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 155 | @next = _dedup_nodes(@attrs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 765 | my @kids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 765 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3267 | my @ch = grep { $_->type ne 'attr' } $n->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 3267 | ▶ | push @kids, grep { (defined($_->name) && $_->name eq $name) } @ch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $_->name && $_->name eq $name
MC/DC50%1/2
defined $_->name && $_->name eq $name
defined $_->name
$_->name eq $name
Truth table66%2/3
A && B
A= defined $_->nameB= $_->name eq $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 765 | @next = _dedup_nodes(@kids); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 923 | ▶ | if ( defined $seg->{i} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | my $idx = $seg->{i}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # interpret as: among matching name children for each parent, pick #idx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | my @picked; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | for my $n (@current) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 44 | my @ch = grep { $_->type ne 'attr' } $n->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 44 | ▶ | my @m = grep { (defined($_->name) && $_->name eq $name) } @ch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $_->name && $_->name eq $name
MC/DC50%1/2
defined $_->name && $_->name eq $name
defined $_->name
$_->name eq $name
Truth table66%2/3
A && B
A= defined $_->nameB= $_->name eq $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 44 | ▶ | push @picked, $m[$idx] if defined $m[$idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | @next = _dedup_nodes(@picked); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | croak "Unknown path segment kind: $seg->{k}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # qualifiers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1308 | ▶ | if ( $seg->{q} && @{$seg->{q}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$seg->{"q"} and @{$seg->{"q"};}
MC/DC50%1/2
$seg->{"q"} and @{$seg->{"q"};}
$seg->{"q"}
@{$seg->{"q"};}
Truth table66%2/3
A and B
A= $seg->{"q"}B= @{$seg->{"q"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | QUALIFIER: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 95 | for my $q (@{$seg->{q}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 96 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$q->{"t"} and $q->{"t"} eq "num" and $q->{"v"} =~ /\A[0-9]+\z/
$q->{"t"} and $q->{"t"} eq "num"
MC/DC33%1/3
$q->{"t"} and $q->{"t"} eq "num" and $q->{"v"} =~ /\A[0-9]+\z/
$q->{"t"}
$q->{"t"} eq "num"
$q->{"v"} =~ /\A[0-9]+\z/
Truth table50%2/4
A and B and C
A= $q->{"t"}B= $q->{"t"} eq "num"C= $q->{"v"} =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | $q->{t} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | and $q->{t} eq 'num' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | and $q->{v} =~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 21 | my $idx = 0 + $q->{v}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 21 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@next and builtin::blessed($next[0]->raw) and $next[0]->raw->isa("XML::LibXML::Node")
@next and builtin::blessed($next[0]->raw)
MC/DC33%1/3
@next and builtin::blessed($next[0]->raw) and $next[0]->raw->isa("XML::LibXML::Node")
@next
builtin::blessed($next[0]->raw)
$next[0]->raw->isa("XML::LibXML::Node")
Truth table50%2/4
A and B and C
A= @nextB= builtin::blessed($next[0]->raw)C= $next[0]->raw->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | @next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | and blessed($next[0]->raw) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | and $next[0]->raw->isa('XML::LibXML::Node') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 20 | ▶ | @next = defined $next[$idx] ? ( $next[$idx] ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | my @picked; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | for my $node (@next) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | my @ch = grep { $_->type ne 'attr' } $node->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | push @picked, $ch[$idx] if defined $ch[$idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | @next = @picked; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 21 | next QUALIFIER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 75 | my @filtered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 75 | ▶ | for ( my $i = 0; $i < @next; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 668 | my $node = $next[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 668 | my $ns_ctx = $ctx->with_nodeset(\@next, \@current); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 668 | my @r = _eval_expr($q, $ns_ctx->with_nodeset([$node], \@next)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 668 | my $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 668 | ▶ | if ( $q->{t} and $q->{t} eq 'path' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$q->{"t"} and $q->{"t"} eq "path"
MC/DC50%1/2
$q->{"t"} and $q->{"t"} eq "path"
$q->{"t"}
$q->{"t"} eq "path"
Truth table66%2/3
A and B
A= $q->{"t"}B= $q->{"t"} eq "path"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 51 | ▶ | $ok = scalar(@r) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 617 | $ok = _truthy($r[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 668 | ▶ | push @filtered, $node if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 75 | @next = @filtered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1308 | $parentset = \@current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1308 | @current = @next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 906 | return @current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 396 | ▶ | sub _eval_fn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval_fn: called CC=168 SCAR=69.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 396 | my ( $fn_ast, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 396 | my $name = $fn_ast->{n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 396 | my @args = @{$fn_ast->{a}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 396 | my $ns = $ctx->nodeset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # helpers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 280 | ▶ | my $eval_arg = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 280 | my ( $i, $local_ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 280 | ▶ | return _eval_expr($args[$i], $local_ctx // $ctx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$local_ctx // $ctx
MC/DC0%0/2
$local_ctx // $ctx
$local_ctx
$ctx
Truth table33%1/3
A // B
A= $local_ctxB= $ctx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 396 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 396 | ▶ | return Data::ZPath::Node->_wrap(!!0) if $name eq 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 395 | ▶ | return Data::ZPath::Node->_wrap(!!1) if $name eq 'true'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 383 | ▶ | return Data::ZPath::Node->_wrap(undef) if $name eq 'null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 382 | ▶ | if ( $name eq 'count' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 68 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 62 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 62 | return Data::ZPath::Node->_wrap(scalar(@r)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 6 | ▶ | my $scope = $ctx->parentset // $ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ctx->parentset // $ns
MC/DC0%0/2
$ctx->parentset // $ns
$ctx->parentset
$ns
Truth table33%1/3
A // B
A= $ctx->parentsetB= $ns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 6 | return Data::ZPath::Node->_wrap(scalar(@$scope)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 314 | ▶ | if ( $name eq 'index' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 25 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # index(expression): for each node matched, its index into its parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 4 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 4 | for my $n (@r) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 3 | ▶ | if ( defined( my $i = $n->ix ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | push @out, Data::ZPath::Node->_wrap(0+$i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | elsif ( defined( my $k = $n->key ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | push @out, Data::ZPath::Node->_wrap(0+$k) if $k =~ /^[0-9]+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # index() within qualifier scope: index of THIS node in parentset; otherwise nodeset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 21 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 21 | ▶ | return unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 21 | ▶ | my $scope = $ctx->parentset // $ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ctx->parentset // $ns
MC/DC0%0/2
$ctx->parentset // $ns
$ctx->parentset
$ns
Truth table66%2/3
A // B
A= $ctx->parentsetB= $ns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 21 | my $ix = $cur->ix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 21 | ▶ | return Data::ZPath::Node->_wrap($ix) if defined $ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | my $id = $cur->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | ▶ | return unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | ▶ | for ( my $i = 0; $i < @$scope; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | my $nid = $scope->[$i]->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | ▶ | if ( defined $nid && $nid eq $id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $nid and $nid eq $id
MC/DC0%0/2
defined $nid and $nid eq $id
defined $nid
$nid eq $id
Truth table33%1/3
A and B
A= defined $nidB= $nid eq $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | return Data::ZPath::Node->_wrap($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return Data::ZPath::Node->_wrap(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 289 | ▶ | if ( $name eq 'key' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 93 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 90 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 90 | my $k = $_->key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 36 | ▶ | defined $k ? Data::ZPath::Node->_wrap($k) : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | ▶ | return unless $cur && defined $cur->key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cur and defined $cur->key
MC/DC0%0/2
$cur and defined $cur->key
$cur
defined $cur->key
Truth table33%1/3
A and B
A= $curB= defined $cur->key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 3 | return Data::ZPath::Node->_wrap($cur->key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 196 | ▶ | if ( $name eq 'union' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 7 | my @all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 7 | for my $i (0 .. $#args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 14 | push @all, $eval_arg->($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 7 | return _dedup_nodes(@all); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 189 | ▶ | if ( $name eq 'intersection' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | return () unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 2 | my @base = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | ▶ | my %have = map { $_->id // ("p:".refaddr(\$_)) => $_ } @base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->id // 'p:' . builtin::refaddr(\$_)
MC/DC0%0/1
$_->id // 'p:' . builtin::refaddr(\$_)
$_->id
Truth table50%1/2
A
A= $_->id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | for my $i (1 .. $#args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | my @r = $eval_arg->($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | ▶ | my %next = map { $_->id // ("p:".refaddr(\$_)) => 1 } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->id // 'p:' . builtin::refaddr(\$_)
MC/DC0%0/1
$_->id // 'p:' . builtin::refaddr(\$_)
$_->id
Truth table50%1/2
A
A= $_->id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | for my $k (keys %have) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | delete $have{$k} unless $next{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | return values %have; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 187 | ▶ | if ( $name eq 'is-first' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | ▶ | return unless $cur && $cur->parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cur and $cur->parent
MC/DC0%0/2
$cur and $cur->parent
$cur
$cur->parent
Truth table33%1/3
A and B
A= $curB= $cur->parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | return Data::ZPath::Node->_wrap($cur->ix == 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 184 | ▶ | if ( $name eq 'is-last' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | my @i = _eval_fn({ t=>'fn', n=>'index', a=>[] }, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 3 | my @c = _eval_fn({ t=>'fn', n=>'count', a=>[] }, $ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | ▶ | return () unless @i && @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@i and @c
MC/DC0%0/2
@i and @c
@i
@c
Truth table33%1/3
A and B
A= @iB= @c
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | return (Data::ZPath::Node->_wrap($i[0]->primitive_value == ($c[0]->primitive_value - 1) ? !!1 : !!0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 181 | ▶ | if ( $name eq 'next' || $name eq 'prev' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name eq "next" or $name eq "prev"
MC/DC100%2/2
$name eq "next" or $name eq "prev"
$name eq "next"
$name eq "prev"
Truth table100%3/3
A or B
A= $name eq "next"B= $name eq "prev"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 88 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 88 | ▶ | return unless $cur && $cur->parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cur and $cur->parent
MC/DC50%1/2
$cur and $cur->parent
$cur
$cur->parent
Truth table66%2/3
A and B
A= $curB= $cur->parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 86 | my @siblings = grep { $_->type ne 'attr' } $cur->parent->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 86 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 86 | for my $ix ( 0 .. $#siblings ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 138 | my $sraw = $siblings[$ix]->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 138 | my $craw = $cur->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 138 | ▶ | if ( blessed($sraw) and blessed($craw) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
builtin::blessed($sraw) and builtin::blessed($craw) and $sraw->isa("XML::LibXML::Node") and $craw->isa("XML::LibXML::Node")
builtin::blessed($sraw) and builtin::blessed($craw) and $sraw->isa("XML::LibXML::Node")
builtin::blessed($sraw) and builtin::blessed($craw)
MC/DC0%0/4
builtin::blessed($sraw) and builtin::blessed($craw) and $sraw->isa("XML::LibXML::Node") and $craw->isa("XML::LibXML::Node")
builtin::blessed($sraw)
builtin::blessed($craw)
$sraw->isa("XML::LibXML::Node")
$craw->isa("XML::LibXML::Node")
Truth table20%1/5
A and B and C and D
A= builtin::blessed($sraw)B= builtin::blessed($craw)C= $sraw->isa("XML::LibXML::Node")D= $craw->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | and $sraw->isa('XML::LibXML::Node') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | and $craw->isa('XML::LibXML::Node') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 138 | ▶ | next unless eval { $sraw->isSameNode($craw) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 86 | $i = $ix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 86 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | next unless defined $siblings[$ix]->id and defined $cur->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $siblings[$ix]->id and defined $cur->id
MC/DC0%0/2
defined $siblings[$ix]->id and defined $cur->id
defined $siblings[$ix]->id
defined $cur->id
Truth table0%0/3
A and B
A= defined $siblings[$ix]->idB= defined $cur->id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ( $siblings[$ix]->id eq $cur->id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $i = $ix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 86 | ▶ | return unless defined $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 86 | ▶ | my $ni = $name eq 'next' ? $i + 1 : $i - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 86 | ▶ | return if $ni < 0 || $ni > $#siblings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ni < 0 or $ni > $#siblings
MC/DC100%2/2
$ni < 0 or $ni > $#siblings
$ni < 0
$ni > $#siblings
Truth table100%3/3
A or B
A= $ni < 0B= $ni > $#siblings
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 34 | return $siblings[$ni]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 93 | ▶ | if ( $name eq 'string' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 7 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 1 | my $s = $_->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | ▶ | defined $s ? Data::ZPath::Node->_wrap($s) : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 6 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 6 | ▶ | return () unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 6 | my $s = $cur->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 6 | ▶ | return defined $s ? (Data::ZPath::Node->_wrap($s)) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 86 | ▶ | if ( $name eq 'number' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 17 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 17 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 17 | my $n = $_->number_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 17 | ▶ | defined $n ? Data::ZPath::Node->_wrap($n) : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | return unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $n = $cur->number_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | return defined $n ? Data::ZPath::Node->_wrap($n) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 69 | ▶ | if ( $name eq 'value' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 8 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 8 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 8 | my $v = $_->primitive_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 8 | Data::ZPath::Node->_wrap($v) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | return unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | return Data::ZPath::Node->_wrap($cur->primitive_value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 61 | ▶ | if ( $name eq 'type' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 14 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 8 | my @r = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 8 | ▶ | return Data::ZPath::Node->_wrap('undefined') unless @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 5 | Data::ZPath::Node->_wrap($_->type) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 6 | my $cur = $ns->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 6 | ▶ | return Data::ZPath::Node->_wrap($cur ? $cur->type : 'undefined'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # Math helpers: map numeric over input set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 12 | ▶ | my $num_input = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 12 | my ( $expr_idx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 12 | ▶ | my @in = @args ? $eval_arg->($expr_idx) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 12 | return map { $_->number_value } @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 47 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 47 | ▶ | if ( $name eq 'ceil' || $name eq 'floor' || $name eq 'round' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$name eq "ceil" or $name eq "floor" or $name eq "round"
$name eq "ceil" or $name eq "floor"
MC/DC100%3/3
$name eq "ceil" or $name eq "floor" or $name eq "round"
$name eq "ceil"
$name eq "floor"
$name eq "round"
Truth table100%4/4
A or B or C
A= $name eq "ceil"B= $name eq "floor"C= $name eq "round"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 4 | my @in = $num_input->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 4 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 4 | for my $x (@in) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 4 | ▶ | next unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 4 | ▶ | my $v = $name eq 'ceil' ? POSIX::ceil($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | : $name eq 'floor' ? POSIX::floor($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | : int($x + ($x >= 0 ? 0.5 : -0.5)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 4 | push @out, Data::ZPath::Node->_wrap($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 4 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 43 | ▶ | if ( $name eq 'sum' || $name eq 'min' || $name eq 'max' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$name eq "sum" or $name eq "min" or $name eq "max"
$name eq "sum" or $name eq "min"
MC/DC100%3/3
$name eq "sum" or $name eq "min" or $name eq "max"
$name eq "sum"
$name eq "min"
$name eq "max"
Truth table100%4/4
A or B or C
A= $name eq "sum"B= $name eq "min"C= $name eq "max"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 5 | my @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 5 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 5 | for my $i ( 0 .. $#args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 8 | push @in, $num_input->($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | @in = $num_input->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 5 | @in = grep { defined } @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 5 | ▶ | return unless @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 5 | ▶ | if ( $name eq 'sum' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 3 | my $s = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 3 | $s += $_ for @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | return Data::ZPath::Node->_wrap($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | ▶ | if ( $name eq 'min' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1 | my $m = $in[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | ▶ | ( $_ < $m ) and ( $m = $_ ) for @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | return Data::ZPath::Node->_wrap($m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | my $m = $in[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | ▶ | ( $_ > $m ) and ( $m = $_ ) for @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1 | return Data::ZPath::Node->_wrap($m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # String helpers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | my $str_input = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my ( $expr_idx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | my @in = @args ? $eval_arg->($expr_idx) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return map { $_->string_value } @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 38 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 38 | ▶ | if ( $name eq 'escape' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | for my $i (0..$#args) { push @in, $eval_arg->($i); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | @in = @$ns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table0%0/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $s =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $s =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $s =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $s =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $s =~ s/'/'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | Data::ZPath::Node->_wrap($s) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 38 | ▶ | if ( $name eq 'unescape' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | for my $i (0..$#args) { push @in, $eval_arg->($i); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | @in = @$ns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table0%0/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $s =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $s =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $s =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $s =~ s/'/'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $s =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | Data::ZPath::Node->_wrap($s) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 38 | ▶ | if ( $name eq 'literal' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # ZTemplate-specific behavior; for Data::ZPath, it's a no-op passthrough | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | for my $i (0..$#args) { push @in, $eval_arg->($i); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | @in = @$ns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 38 | ▶ | if ( $name eq 'format' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | ▶ | croak "format(format, expression)" unless @args >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | my @fmt = $eval_arg->(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | ▶ | my $f = $fmt[0] ? ($fmt[0]->string_value // '') : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$fmt[0]->string_value // ""
MC/DC0%0/1
$fmt[0]->string_value // ""
$fmt[0]->string_value
Truth table50%1/2
A
A= $fmt[0]->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 1 | ▶ | my @in = @args > 1 ? $eval_arg->(1) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 1 | my $v = $_->primitive_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | Data::ZPath::Node->_wrap(sprintf($f, $v)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 37 | ▶ | if ( $name eq 'index-of' || $name eq 'last-index-of' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "index-of" or $name eq "last-index-of"
MC/DC50%1/2
$name eq "index-of" or $name eq "last-index-of"
$name eq "index-of"
$name eq "last-index-of"
Truth table66%2/3
A or B
A= $name eq "index-of"B= $name eq "last-index-of"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | ▶ | croak "$name(search, expression)" unless @args >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | ▶ | my $search = ($eval_arg->(0))[0]->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(0))[0]->string_value // ""
MC/DC0%0/1
(&$eval_arg(0))[0]->string_value // ""
(&$eval_arg(0))[0]->string_value
Truth table50%1/2
A
A= (&$eval_arg(0))[0]->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | ▶ | my @in = @args > 1 ? $eval_arg->(1) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 2 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | ▶ | my $pos = $name eq 'index-of' ? index($search, $s) : rindex($search, $s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 2 | Data::ZPath::Node->_wrap($pos) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 35 | ▶ | if ( $name eq 'string-length' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 2 | ▶ | my @in = @args ? $eval_arg->(0) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | Data::ZPath::Node->_wrap(length($s)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 33 | ▶ | if ( $name eq 'upper-case' || $name eq 'lower-case' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name eq "upper-case" or $name eq "lower-case"
MC/DC100%2/2
$name eq "upper-case" or $name eq "lower-case"
$name eq "upper-case"
$name eq "lower-case"
Truth table100%3/3
A or B
A= $name eq "upper-case"B= $name eq "lower-case"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 2 | ▶ | my @in = @args ? $eval_arg->(0) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 2 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | ▶ | $s = $name eq 'upper-case' ? uc($s) : lc($s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 2 | Data::ZPath::Node->_wrap($s) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 31 | ▶ | if ( $name eq 'substring' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | ▶ | croak "substring(expression, start, length)" unless @args >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | ▶ | my @in = @args > 2 ? $eval_arg->(0) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | ▶ | my $start = ($eval_arg->(1))[0]->number_value // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(1))[0]->number_value // 0
MC/DC0%0/1
(&$eval_arg(1))[0]->number_value // 0
(&$eval_arg(1))[0]->number_value
Truth table50%1/2
A
A= (&$eval_arg(1))[0]->number_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 1 | ▶ | my $len = ($eval_arg->(2))[0]->number_value // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(2))[0]->number_value // 0
MC/DC0%0/1
(&$eval_arg(2))[0]->number_value // 0
(&$eval_arg(2))[0]->number_value
Truth table50%1/2
A
A= (&$eval_arg(2))[0]->number_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 1 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 1 | Data::ZPath::Node->_wrap(substr($s, int($start), int($len))) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 30 | ▶ | if ( $name eq 'match' || $name eq 'matches' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "match" or $name eq "matches"
MC/DC50%1/2
$name eq "match" or $name eq "matches"
$name eq "match"
$name eq "matches"
Truth table66%2/3
A or B
A= $name eq "match"B= $name eq "matches"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 1 | ▶ | croak "match(pattern, expression)" unless @args >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 1 | ▶ | my $pat = ($eval_arg->(0))[0]->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(0))[0]->string_value // ""
MC/DC0%0/1
(&$eval_arg(0))[0]->string_value // ""
(&$eval_arg(0))[0]->string_value
Truth table50%1/2
A
A= (&$eval_arg(0))[0]->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 1 | my $re = _pattern_to_regexp( $pat ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 1 | ▶ | my @in = @args > 1 ? $eval_arg->(1) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 1 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 1 | ▶ | Data::ZPath::Node->_wrap(($s =~ $re) ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 29 | ▶ | if ( $name eq 'replace' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 13 | ▶ | croak "replace(pattern, replace, expression)" unless @args >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 13 | ▶ | my $pat = ($eval_arg->(0))[0]->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(0))[0]->string_value // ""
MC/DC0%0/1
(&$eval_arg(0))[0]->string_value // ""
(&$eval_arg(0))[0]->string_value
Truth table50%1/2
A
A= (&$eval_arg(0))[0]->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 13 | ▶ | my $rep = ($eval_arg->(1))[0]->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(1))[0]->string_value // ""
MC/DC0%0/1
(&$eval_arg(1))[0]->string_value // ""
(&$eval_arg(1))[0]->string_value
Truth table50%1/2
A
A= (&$eval_arg(1))[0]->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 13 | my $re = _pattern_to_regexp( $pat ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 13 | ▶ | my @in = @args > 2 ? $eval_arg->(2) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 13 | ▶ | my $s = $_->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 13 | Data::ZPath::Node->_wrap(_string_replace($s, $re, $rep)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 16 | ▶ | if ( $name eq 'join' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 3 | ▶ | croak "join(joiner, expression)" unless @args >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 3 | ▶ | my $joiner = ($eval_arg->(0))[0]->string_value // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(&$eval_arg(0))[0]->string_value // ""
MC/DC0%0/1
(&$eval_arg(0))[0]->string_value // ""
(&$eval_arg(0))[0]->string_value
Truth table50%1/2
A
A= (&$eval_arg(0))[0]->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 3 | ▶ | my @in = @args > 1 ? $eval_arg->(1) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 3 | ▶ | my @ss = map { $_->string_value // '' } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->string_value // ""
MC/DC0%0/1
$_->string_value // ""
$_->string_value
Truth table50%1/2
A
A= $_->string_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 3 | return Data::ZPath::Node->_wrap(join($joiner, @ss)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # XML functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 13 | ▶ | if ( $name eq 'url' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 12 | ▶ | my @in = @args ? $eval_arg->(0) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 12 | my $raw = $_->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 12 | my $u = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 12 | ▶ | if ( blessed($raw) && $raw->can('namespaceURI') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($raw) and $raw->can("namespaceURI")
MC/DC50%1/2
builtin::blessed($raw) and $raw->can("namespaceURI")
builtin::blessed($raw)
$raw->can("namespaceURI")
Truth table66%2/3
A and B
A= builtin::blessed($raw)B= $raw->can("namespaceURI")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 11 | ▶ | $u = $raw->namespaceURI // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$raw->namespaceURI // ""
MC/DC100%1/1
$raw->namespaceURI // ""
$raw->namespaceURI
Truth table100%2/2
A
A= $raw->namespaceURI
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 12 | Data::ZPath::Node->_wrap($u) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 1 | ▶ | if ( $name eq 'local-name' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | my @in = @args ? $eval_arg->(0) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $raw = $_->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my $ln = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | if ( blessed($raw) && $raw->can('localname') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($raw) and $raw->can("localname")
MC/DC0%0/2
builtin::blessed($raw) and $raw->can("localname")
builtin::blessed($raw)
$raw->can("localname")
Truth table0%0/3
A and B
A= builtin::blessed($raw)B= $raw->can("localname")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | $ln = $raw->localname // ($raw->nodeName // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$raw->localname // ($raw->nodeName // "")
$raw->nodeName // ""
MC/DC0%0/2
$raw->localname // ($raw->nodeName // "")
$raw->localname
$raw->nodeName
Truth table0%0/3
A // B
A= $raw->localnameB= $raw->nodeName
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | $ln = $_->name // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->name // ""
MC/DC0%0/1
$_->name // ""
$_->name
Truth table0%0/2
A
A= $_->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | Data::ZPath::Node->_wrap($ln) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | # CBOR tag() (optional marker), returns empty set if absent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 1 | ▶ | if ( $name eq 'tag' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 1 | ▶ | my @in = @args ? $eval_arg->(0) : @$ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 1 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 1 | for my $n (@in) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 1 | my $raw = $n->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 1 | ▶ | if ( blessed($raw) and $raw->isa('CBOR::Free::Tagged') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($raw) and $raw->isa("CBOR::Free::Tagged")
MC/DC0%0/2
builtin::blessed($raw) and $raw->isa("CBOR::Free::Tagged")
builtin::blessed($raw)
$raw->isa("CBOR::Free::Tagged")
Truth table33%1/3
A and B
A= builtin::blessed($raw)B= $raw->isa("CBOR::Free::Tagged")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 1 | push @out, Data::ZPath::Node->_wrap($raw->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 1 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | croak "Unknown function '$name'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 13 | ▶ | sub _string_replace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_string_replace: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 13 | my ( $string, $pattern, $replacement ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 13 | my @matches = ( $string =~ /$pattern/p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 13 | unshift @matches, ${^MATCH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 13 | $string =~ s{$pattern}{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 12 | my $r = "$replacement"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 12 | $r =~ s{ \$ ([0-9]+) }{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 5 | ▶ | $1 <= $#matches ? $matches[$1] : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | }xeg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 12 | $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | }eg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 13 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 1152 | ▶ | sub _dedup_nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dedup_nodes: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 1152 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1152 | my $raw = $_->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 4151 | my $key = $_->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 4151 | ▶ | if ( blessed($raw) and $raw->isa('XML::LibXML::Node') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($raw) and $raw->isa("XML::LibXML::Node")
MC/DC100%2/2
builtin::blessed($raw) and $raw->isa("XML::LibXML::Node")
builtin::blessed($raw)
$raw->isa("XML::LibXML::Node")
Truth table100%3/3
A and B
A= builtin::blessed($raw)B= $raw->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1984 | ▶ | $key = join ':', 'xmlpath', $raw->nodeType, ($raw->nodePath // q{}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$raw->nodePath // ""
MC/DC0%0/1
$raw->nodePath // ""
$raw->nodePath
Truth table50%1/2
A
A= $raw->nodePath
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 4151 | not $seen{$key}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 681 | ▶ | sub _truthy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_truthy: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 681 | my ( $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 681 | ▶ | return !!0 unless $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 673 | my $pv = $n->primitive_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 673 | return !!$pv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 93 | ▶ | sub _to_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_number: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 93 | my ( $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 93 | ▶ | return undef unless $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 93 | return $n->number_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | sub _to_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_string: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | my ( $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | return undef unless $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | return $n->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 228 | ▶ | sub _equals { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_equals: called CC=15 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 228 | my ( $a, $b ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 228 | ▶ | return !!0 unless $a && $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$a and $b
MC/DC0%0/2
$a and $b
$a
$b
Truth table33%1/3
A and B
A= $aB= $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 228 | my $a_type = $a->type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 228 | my $b_type = $b->type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 228 | ▶ | return $a_type eq 'null' if $b_type eq 'null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 228 | ▶ | return $b_type eq 'null' if $a_type eq 'null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 228 | ▶ | if ( $a_type eq 'boolean' and $b_type eq 'boolean' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$a_type eq "boolean" and $b_type eq "boolean"
MC/DC0%0/2
$a_type eq "boolean" and $b_type eq "boolean"
$a_type eq "boolean"
$b_type eq "boolean"
Truth table33%1/3
A and B
A= $a_type eq "boolean"B= $b_type eq "boolean"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | my $av = !!$a->primative_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | my $bv = !!$b->primative_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | return $av == $bv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 228 | ▶ | if ( $a_type eq 'number' and $b_type eq 'number' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$a_type eq "number" and $b_type eq "number"
MC/DC50%1/2
$a_type eq "number" and $b_type eq "number"
$a_type eq "number"
$b_type eq "number"
Truth table66%2/3
A and B
A= $a_type eq "number"B= $b_type eq "number"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 67 | my $av = $a->number_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 67 | my $bv = $b->number_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | # Floating point comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 67 | ▶ | if ( $av =~ /\./ or $bv =~ /\./ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$av =~ /\./ or $bv =~ /\./
MC/DC50%1/2
$av =~ /\./ or $bv =~ /\./
$av =~ /\./
$bv =~ /\./
Truth table66%2/3
A or B
A= $av =~ /\./B= $bv =~ /\./
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | return abs($av-$bv) < $Data::ZPath::Epsilon; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 66 | return $av == $bv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 161 | my @string_like = qw( string text attr comment element ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 161 | ▶ | if ( grep { $a_type eq $_ } @string_like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
grep {$a_type eq $_;} @string_like and grep {$b_type eq $_;} @string_like
MC/DC100%2/2
grep {$a_type eq $_;} @string_like and grep {$b_type eq $_;} @string_like
grep {$a_type eq $_;} @string_like
grep {$b_type eq $_;} @string_like
Truth table100%3/3
A and B
A= grep {$a_type eq $_;} @string_likeB= grep {$b_type eq $_;} @string_like
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 790 | and grep { $b_type eq $_ } @string_like ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 140 | my $av = $a->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 140 | my $bv = $b->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 140 | return "$av" eq "$bv"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 21 | ▶ | return unless $a->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 3 | ▶ | return unless $b->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 2 | return $a->id eq $b->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||