lib/Test/Pod/Coverage/More.pm

filter: Statementstmt 92.0% 46 / 50 Branchbran 50.0% 5 / 10 Conditioncond 66.6% 8 / 12 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 81.8% 72 / 88 CC 16 SCAR 23.7
CC
16
Cov
82%
pod_coverage_more_ok
17.2
all_pod_coverage_more_ok
4.0
BEGIN
1.0
CRAP 10.7
« lib/Pod/Coverage/More/Declared/MOP.pm ↑ Summary blib/lib/Pod/Coverage/More/Generator.pm »
1 # ABSTRACT: Test that the POD of a module says what each sub takes, returns, and how it fails
2 # PODNAME: Test::Pod::Coverage::More
3  
4 package Test::Pod::Coverage::More 0.003;
5  
6 5 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use warnings FATAL => q{all};
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use Exporter qw{import};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Test::Pod::Coverage ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 ▶use Pod::Coverage::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # A test module exports its test functions, as Test::More and Test::Pod::Coverage do.
16 5 our @EXPORT = qw{pod_coverage_more_ok all_pod_coverage_more_ok}; ## no critic (Modules::ProhibitAutomaticExportation)
17  
18  
19 5 our $TEST = Test::Builder->new;
20  
21 7 ▶sub pod_coverage_more_ok {
Subroutine pod_coverage_more_ok: called CC=13 SCAR=28.5
Pod documented
22 7 my ( $module, $options, $name ) = @_;
23 7 ▶ my %args = %{ $options // {} };
Condition100%2/2
$options // {}
l!l
25
MC/DC100%1/1
$options // {}
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
24 7 ▶ my $checks = delete( $args{checks} ) // \@Pod::Coverage::More::CHECKS;
Condition100%2/2
delete $args{"checks"} // \@Pod::Coverage::More::CHECKS
l!l
25
MC/DC100%1/1
delete $args{"checks"} // \@Pod::Coverage::More::CHECKS
delete $args{"checks"}
Truth table100%2/2
A
A= delete $args{"checks"}
Aresult
11
00
25 7 ▶ $name //= "POD coverage of $module";
Condition100%2/2
$name //= "POD coverage of $module"
l!l
16
MC/DC100%1/1
$name //= "POD coverage of $module"
$name
Truth table100%2/2
A
A= $name
Aresult
11
00
26  
27 7 my $pc = Pod::Coverage::More->new( package => $module, %args );
28 7 my $rating = $pc->coverage;
29 7 my @failures;
30 7 ▶ if ( !defined $rating ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $rating) { } 0 7 7
elsif ($rating < 1) { } 0 7 7
31 0 ▶ my $why = $pc->why_unrated // 'it could not be rated';
Condition0%0/2
$pc->why_unrated // "it could not be rated"
l!l
00
MC/DC0%0/1
$pc->why_unrated // "it could not be rated"
$pc->why_unrated
Truth table0%0/2
A
A= $pc->why_unrated
Aresult
11
00
32 0 ▶ push @failures, "$module: $why" if $why ne 'no public symbols defined';
Branch: 1 branch
BranchTrueFalseTotal
if $why ne "no public symbols defined" 0 0 0
33 }
34 elsif ( $rating < 1 ) {
35 0 push @failures, map { "$module: $_ is not documented" } sort $pc->naked;
36 }
37  
38 7 ▶ my $report = $pc->coverage_report // {};
Condition50%1/2
$pc->coverage_report // {}
l!l
70
MC/DC0%0/1
$pc->coverage_report // {}
$pc->coverage_report
Truth table50%1/2
A
A= $pc->coverage_report
Aresult
11
00
39 7 foreach my $sub ( sort keys %$report ) {
40 67 foreach my $check (@$checks) {
41 56 ▶ push @failures, map { "$module: $_" } @{ $report->{$sub}{failures}{$check} || [] };
Condition50%1/2
$report->{$sub}{'failures'}{$check} || []
l!l
560
MC/DC0%0/1
$report->{$sub}{'failures'}{$check} || []
$report->{$sub}{'failures'}{$check}
Truth table50%1/2
A
A= $report->{$sub}{'failures'}{$check}
Aresult
11
00
42 }
43 }
44  
45 7 my $ok = $TEST->ok( !@failures, $name );
46 7 foreach my $failure (@failures) {
47 2 $TEST->diag($failure);
48 }
49 7 return $ok;
50 }
51  
52  
53 4 ▶sub all_pod_coverage_more_ok {
Subroutine all_pod_coverage_more_ok: called CC=4 SCAR=13.9
Pod documented
54 4 my ($options) = @_;
55 4 my @modules = Test::Pod::Coverage::all_modules();
56 4 ▶ $TEST->plan( tests => scalar @modules ) if !$TEST->has_plan;
Branch: 1 branch
BranchTrueFalseTotal
unless $Test::Pod::Coverage::More::TEST->has_plan 4 0 4
57 4 my $ok = 1;
58 4 foreach my $module (@modules) {
59 4 ▶ $ok = 0 if !pod_coverage_more_ok( $module, $options );
Branch: 1 branch
BranchTrueFalseTotal
unless pod_coverage_more_ok($module, $options) 1 3 4
60 }
61 4 return $ok;
62 }
63  
64 5 1;
65  
66 __END__
« lib/Pod/Coverage/More/Declared/MOP.pm ↑ Summary blib/lib/Pod/Coverage/More/Generator.pm »