NDBin/Action/CodeRef.pm

filter: Statementstmt 50.0% 14 / 28 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 47.7% 21 / 44 CC 4 SCAR 21.7
CC
4
Cov
41%
process
20.0
new
2.0
result
2.0
CRAP 8.8
↑ Summary NDBin/Iterator.pm »
1 package PDL::NDBin::Action::CodeRef;
2 # ABSTRACT: Action for PDL::NDBin that calls user sub
3 2 $PDL::NDBin::Action::CodeRef::VERSION = '0.016';
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use PDL::Lite; # do not import any functions into this namespace
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Params::Validate qw( validate CODEREF OBJECT SCALAR UNDEF );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 sub new
12 {
13 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
14 0 my $self = validate( @_, {
15 N => { type => SCALAR, regex => qr/^\d+$/ },
16 coderef => { type => CODEREF },
17 type => { type => OBJECT | UNDEF, isa => 'PDL::Type', optional => 1 }
18 } );
19 0 return bless $self, $class;
20 }
21  
22  
23 sub process
24 {
25 0 ▶ my $self = shift;
Subroutine process: not called CC=4 SCAR=30.0
Pod documented
26 0 my $iter = shift;
27 0 ▶ if( ! defined $self->{out} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"out"}) 0 0 0
28 0 ▶ my $type = defined $self->{type} ? $self->{type} : $iter->data->type;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'type'} ? : 0 0 0
29 0 $self->{out} = PDL->zeroes( $type, $self->{N} )->setbadif( 1 );
30 }
31 0 my $value = $self->{coderef}->( $iter );
32 0 ▶ if( defined $value ) { $self->{out}->set( $iter->bin, $value ) }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
33 0 return $self;
34 }
35  
36  
37 sub result
38 {
39 0 ▶ my $self = shift;
Subroutine result: not called CC=1 SCAR=6.9
Pod documented
40 0 return $self->{out};
41 }
42  
43 2 1;
44  
45 __END__
↑ Summary NDBin/Iterator.pm »