blib/lib/Loop/Util.pm

filter: Statementstmt 71.7% 28 / 39 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 67.8% 38 / 56 CC 11 SCAR 21.5
CC
11
Cov
67%
import
10.5
import
10.5
BEGIN
1.0
CRAP 8.6
↑ Summary Util.xs »
1 11 ▶use 5.014000;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Loop::Util;
6  
7 11 our $AUTHORITY = 'cpan:TOBYINK';
8 11 our $VERSION = '0.001000';
9  
10 # These are dynamically scoped by the rewritten loop keywords.
11 11 our ( $LOOPKIND, $LENGTH, $ITERATION );
12  
13 11 my @ALL_KEYWORDS = qw( loop iffirst iflast ifodd ifeven __IX__ );
14 11 my %VALID = map { $_ => 1 } @ALL_KEYWORDS;
15  
16 13 ▶sub import {
Subroutine import: called CC=6 SCAR=23.5
17 13 ▶ my ( $class, @keywords ) = @_;
Subroutine import: not called CC=6 SCAR=23.5
18  
19 13 ▶ if ( !@keywords ) {
Branch: 2 branches
BranchTrueFalseTotal
unless (@keywords) 9 4 13
unless (@keywords) 0 0 0
20 9 @keywords = @ALL_KEYWORDS;
21 }
22  
23 13 for my $keyword ( @keywords ) {
24 die "Unknown Loop::Util keyword '$keyword'"
25 61 ▶ if not exists $VALID{ $keyword };
Branch: 2 branches
BranchTrueFalseTotal
unless exists $VALID{$keyword} 1 60 61
unless exists $VALID{$keyword} 0 0 0
26 }
27  
28 12 my %enabled = map { $_ => 1 } @keywords;
29  
30 12 for my $keyword ( @ALL_KEYWORDS ) {
31 72 ▶ if ( exists $enabled{ $keyword } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $enabled{$keyword}) { } 60 12 72
if (exists $enabled{$keyword}) { } 0 0 0
32 60 $^H{ "Loop::Util/$keyword" } = 1;
33 }
34 else {
35 12 delete $^H{ "Loop::Util/$keyword" };
36 }
37 }
38 }
39  
40 11 require XSLoader;
41 11 XSLoader::load( __PACKAGE__, $VERSION );
42  
43 11 __PACKAGE__
44 __END__
↑ Summary Util.xs »