blib/lib/TAP/SimpleOutput.pm

filter: Statementstmt 73.0% 38 / 52 Branchbran 22.2% 4 / 18 Conditioncond 40.0% 2 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 73.6% 14 / 19 Podpod 100% 5 / 5 totaltotal 62.7% 64 / 102 CC 13 SCAR 20.3
CC
13
Cov
59%
subtest_header_needed
20.0
subtest_header
20.0
__ANON__
12.0
CRAP 7.6
↑ Summary
1 #
2 # This file is part of TAP-SimpleOutput
3 #
4 # This software is Copyright (c) 2012 by Chris Weyl.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package TAP::SimpleOutput;
11 2 our $AUTHORITY = 'cpan:RSRCHBOY';
12 # git description: 0.007-1-g6755323
13 2 $TAP::SimpleOutput::VERSION = '0.008';
14  
15 # ABSTRACT: Simple closure-driven TAP generator
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 use Sub::Exporter::Progressive -setup => {
21 exports => [ qw{
22 counters counters_and_levelset counters_as_hashref
23 subtest_header subtest_header_needed
24 } ],
25 groups => {
26 default => [ 'counters' ],
27 subtest => [ qw{ counters subtest_header subtest_header_needed } ],
28 },
29 2 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 2 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
32 2 ▶use Class::Load 'try_load_class';
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34  
35 sub counters {
36 6 ▶ my $level = shift @_;
Subroutine counters: called CC=2 SCAR=6.9
Pod documented
37  
38 6 ▶ return { _build_counters($level) }
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 2 4 6
39 unless wantarray;
40  
41 4 my $i = 0;
42 my @counters =
43 4 grep { $i++ % 2 }
44 _build_counters($level)
45 ;
46  
47 # ditch levelset
48 4 pop @counters;
49  
50 4 return @counters;
51 }
52  
53  
54 1 ▶sub counters_as_hashref { scalar counters }
Subroutine counters_as_hashref: called CC=1 SCAR=0.0
Pod documented
55  
56  
57 0 ▶sub counters_and_levelset { goto \&_build_counters }
Subroutine counters_and_levelset: not called CC=1 SCAR=6.9
Pod documented
58  
59 sub _build_counters {
60 6 ▶ my $level = shift @_ || 0;
Subroutine _build_counters: called CC=3 SCAR=12.2
Condition100%2/2
shift @_ || 0
l!l
24
MC/DC100%1/1
shift @_ || 0
shift @_
Truth table100%2/2
A
A= shift @_
Aresult
11
00
61 6 $level *= 4;
62 6 my $i = 0;
63  
64 6 ▶ my $indent = !$level ? q{} : (' ' x $level);
Branch: 1 branch
BranchTrueFalseTotal
!$level ? : 4 2 6
65  
66 return (
67 19 ▶ ok => sub { $indent . 'ok ' . ++$i . " - $_[0]" },
Subroutine __ANON__: called CC=1 SCAR=0.0
68 5 ▶ nok => sub { $indent . 'not ok ' . ++$i . " - $_[0]" },
Subroutine __ANON__: called CC=1 SCAR=0.0
69 5 ▶ skip => sub { $indent . 'ok ' . ++$i . " # skip $_[0]" },
Subroutine __ANON__: called CC=1 SCAR=0.0
70 5 ▶ plan => sub { $indent . "1..$i" },
Subroutine __ANON__: called CC=1 SCAR=0.0
71 5 ▶ todo => sub { "$_[0] # TODO $_[1]" },
Subroutine __ANON__: called CC=1 SCAR=0.0
72 4 ▶ freeform => sub { $indent . "$_[0]" },
Subroutine __ANON__: called CC=1 SCAR=0.0
73 levelset => sub {
74 # if we're called with a new level, set $level and $indent
75 # appropriately
76 0 ▶ do { $level = $_[0] * 4; $indent = !$level ? q{} : (' ' x $level) }
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
!$level ? : 0 0 0
77 if defined $_[0];
78  
79 # return our new/set level regardless, in the form we passed it in
80 0 return $level / 4;
81 },
82 6 );
83 }
84  
85  
86 2 my $_subtest_header_needed;
87 sub subtest_header_needed {
88  
89 0 ▶ return $_subtest_header_needed
Subroutine subtest_header_needed: not called CC=4 SCAR=30.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if defined $_subtest_header_needed 0 0 0
90 if defined $_subtest_header_needed;
91  
92 do {
93 0 my ($success, $error) = try_load_class $_;
94 0 ▶ croak __PACKAGE__ . " needs $_, but can't find it: $error"
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 0 0
95 unless $success;
96 0 } for qw{ Perl::Version Test::More };
97  
98 0 return $_subtest_header_needed
99 = Perl::Version->new(Test::More->VERSION) >= Perl::Version->new('0.98_05');
100 }
101  
102 0 ▶sub _subtest_header_indent { $INC{'Test/Stream.pm'} ? q{} : (' ' x 4) }
Subroutine _subtest_header_indent: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$INC{'Test/Stream.pm'} ? : 0 0 0
103  
104  
105 sub subtest_header {
106 0 ▶ my ($out, $name) = @_;
Subroutine subtest_header: not called CC=4 SCAR=30.0
Pod documented
107  
108 $out = $out->{freeform}
109 0 ▶ if ref $out && ref $out eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $out and ref $out eq "HASH" 0 0 0
Condition0%0/3
ref $out and ref $out eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $out and ref $out eq "HASH"
ref $out ref $out eq "HASH"
Truth table0%0/3
A and B
A= ref $outB= ref $out eq "HASH"
ABresult
0X0
100
111
110  
111 0 ▶ return subtest_header_needed()
Branch: 1 branch
BranchTrueFalseTotal
subtest_header_needed() ? : 0 0 0
112 ? $out->(_subtest_header_indent . "# Subtest: $name")
113 : q{}
114 ;
115 }
116  
117 2 !!42;
118  
119 __END__
↑ Summary