LINQ.pm

filter: Statementstmt 100% 70 / 70 Branchbran 100% 22 / 22 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 15 / 15 Podpod 100% 3 / 3 totaltotal 100% 115 / 115 CC 13 SCAR 9.9
CC
13
Cov
100%
LINQ
6.0
Range
3.0
__ANON__
2.0
CRAP 2.7
« LINQ/Field.pm ↑ Summary LINQ/FieldSet/Single.pm »
1 116 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 116 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 116 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package LINQ;
6  
7 116 our $AUTHORITY = 'cpan:TOBYINK';
8 116 our $VERSION = '0.003';
9  
10 116 ▶use Exporter::Shiny qw( LINQ Range Repeat END );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 116 our $FORCE_ITERATOR;
13 116 our $IN_LOOP;
14  
15 116 my $end = do {
16  
17 package LINQ::END;
18 116 our $AUTHORITY = 'cpan:TOBYINK';
19 116 our $VERSION = '0.003';
20 116 my $x = 42;
21 116 bless( \$x );
22 116 &Internals::SvREADONLY( \$x, !!1 );
23 116 \$x;
24 };
25  
26 116 my $last = do {
27  
28 package LINQ::LAST;
29 116 our $AUTHORITY = 'cpan:TOBYINK';
30 116 our $VERSION = '0.003';
31 116 my $x = 666;
32 116 bless( \$x );
33 116 &Internals::SvREADONLY( \$x, !!1 );
34 116 \$x;
35 };
36  
37 116 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
38 116 ▶ *LINQ::END = sub () { $end };
Subroutine __ANON__: called CC=1 SCAR=0.0
39
40 6 ▶ *LINQ::LAST = sub () {
Subroutine __ANON__: called CC=2 SCAR=6.9
41 6 ▶ if ( $IN_LOOP ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LINQ::IN_LOOP) 3 3 6
42 3 die( $last );
43 }
44 3 require LINQ::Exception;
45 3 'LINQ::Exception::CallerError'->throw(
46 message => "Cannot call LINQ::LAST outside foreach",
47 );
48 116 };
49 } #/ BEGIN
50  
51 793 ▶sub LINQ ($) {
Subroutine LINQ: called CC=6 SCAR=17.9
Pod documented
52 793 my $data = shift;
53 793 my $ref = ref( $data );
54
55 793 ▶ if ( $ref eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq "ARRAY") 473 320 793
56 473 ▶ if ( $FORCE_ITERATOR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LINQ::FORCE_ITERATOR) 216 257 473
57 216 my @data = @$data;
58 216 require LINQ::Iterator;
59 216 ▶ return LINQ::Iterator::->new( sub { @data ? shift( @data ) : LINQ::END } );
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@data ? : 1068 183 1251
60 }
61
62 257 require LINQ::Array;
63 257 return LINQ::Array::->new( $data );
64 } #/ if ( $ref eq 'ARRAY' )
65
66 320 ▶ if ( $ref eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq "CODE") 317 3 320
67 317 require LINQ::Iterator;
68 317 return LINQ::Iterator::->new( $data );
69 }
70
71 3 require Scalar::Util;
72 3 ▶ if ( Scalar::Util::blessed( $data ) and $data->DOES( 'LINQ::Collection' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($data) and $data->DOES("LINQ::Collection")) 1 2 3
Condition100%3/3
builtin::blessed($data) and $data->DOES("LINQ::Collection")
!ll&&!rl&&r
111
MC/DC100%2/2
builtin::blessed($data) and $data->DOES("LINQ::Collection")
builtin::blessed($data) $data->DOES("LINQ::Collection")
Truth table100%3/3
A and B
A= builtin::blessed($data)B= $data->DOES("LINQ::Collection")
ABresult
0X0
100
111
73 1 return $data;
74 }
75
76 2 require LINQ::Exception;
77 2 'LINQ::Exception::CallerError'->throw(
78 message => "Cannot create LINQ object from '$data'",
79 );
80 } #/ sub LINQ ($)
81  
82 7 ▶sub Range {
Subroutine Range: called CC=3 SCAR=11.0
Pod documented
83 7 my ( $min, $max ) = @_;
84
85 7 ▶ my $value = defined( $min ) ? $min : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $min ? : 6 1 7
86
87 7 ▶ if ( not defined $max ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $max) 2 5 7
88 2 ▶ return LINQ sub { $value++ };
Subroutine __ANON__: called CC=1 SCAR=0.0
89 }
90
91 5 ▶ return LINQ sub { return LINQ::END if $value > $max; $value++ };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $value > $max 4 31 35
92 } #/ sub Range
93  
94 6 ▶sub Repeat {
Subroutine Repeat: called CC=2 SCAR=6.9
Pod documented
95 6 my ( $value, $count ) = @_;
96
97 6 ▶ if ( not defined $count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $count) 5 1 6
98 5 ▶ return LINQ sub { $value };
Subroutine __ANON__: called CC=1 SCAR=0.0
99 }
100
101 1 ▶ return LINQ sub { return LINQ::END if $count-- <= 0; $value };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $count-- <= 0 1 7 8
102 }
103  
104 116 1;
105  
106 __END__
« LINQ/Field.pm ↑ Summary LINQ/FieldSet/Single.pm »