Data/Frame/Partial/Eval.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 58.3% 7 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 83.6% 51 / 61 CC 8 SCAR 17.1
CC
8
Cov
84%
eval_tidy
8.9
BEGIN
1.0
BEGIN
1.0
CRAP 5.5
« Test2/Tools/DataFrame.pm ↑ Summary Data/Frame/Util.pm »
1 package Data::Frame::Partial::Eval;
2 11 $Data::Frame::Partial::Eval::VERSION = '0.006005';
3 # ABSTRACT: Partial class for data frame's eval method
4  
5 11 ▶use Data::Frame::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use Eval::Quosure 0.001001;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Types::Standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶use Data::Frame::Indexer qw(indexer_s);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 3 ▶method eval_tidy ($x) {
Subroutine eval_tidy: called CC=8 SCAR=21.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for method eval_tidy (expected 2, got ' . @_ . ')') 0 3 3
@_ > 2 and Function::Parameters::_croak('Too many arguments for method eval_tidy (expected 2, got ' . @_ . ')') 0 3 3
15 3 my $is_quosure = $x->$_DOES('Eval::Quosure');
16 3 ▶ if (ref($x) and not $is_quosure) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x and not $is_quosure) 0 3 3
Condition33%1/3
ref $x and not $is_quosure
!ll&&!rl&&r
300
MC/DC0%0/2
ref $x and not $is_quosure
ref $x not $is_quosure
Truth table33%1/3
A and not(B)
A= ref $xB= not $is_quosure
ABresult
0X0
100
111
17 0 return $x;
18 }
19  
20 3 ▶ my $expr = $is_quosure ? $x->expr : $x;
Branch: 1 branch
BranchTrueFalseTotal
$is_quosure ? : 0 3 3
21 3 ▶ if ( $self->exists($expr) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->exists($expr)) 1 2 3
22 1 return $self->column($expr);
23 }
24  
25 2 ▶ my $quosure = $is_quosure ? $x : Eval::Quosure->new( $expr, 1 );
Branch: 1 branch
BranchTrueFalseTotal
$is_quosure ? : 0 2 2
26  
27 # If expr matches a column name in the data frame, return the column.
28 my $column_vars = {
29 $self->names->map(
30 22 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
31 22 my $var = '$' . ( $_ =~ s/\W/_/gr );
32 22 $var => $self->at($_);
33 }
34 2 )->flatten
35 };
36  
37 2 try {
38 2 return $quosure->eval($column_vars);
39 }
40 catch ($e) {
41 1 die qq{Error in eval_tidy('$expr', ...) : $e };
42 }
43 11 }
44  
45 11 1;
46  
47 __END__
« Test2/Tools/DataFrame.pm ↑ Summary Data/Frame/Util.pm »