Test/Pod/Coverage/More.pm

filter: Statementstmt 92.0% 46 / 50 Branchbran 40.0% 4 / 10 Conditioncond 66.6% 8 / 12 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 80.6% 71 / 88 CC 16 SCAR 23.7
CC
16
Cov
81%
pod_coverage_more_ok
17.2
all_pod_coverage_more_ok
4.1
BEGIN
1.0
CRAP 10.7
« Pod/Coverage/More/Declared/MOP.pm ↑ Summary 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.001;
5  
6 2 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings FATAL => q{all};
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Exporter qw{import};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Test::Pod::Coverage ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶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 2 our @EXPORT = qw{pod_coverage_more_ok all_pod_coverage_more_ok}; ## no critic (Modules::ProhibitAutomaticExportation)
17  
18  
19 2 our $TEST = Test::Builder->new;
20  
21 4 ▶sub pod_coverage_more_ok {
Subroutine pod_coverage_more_ok: called CC=13 SCAR=28.5
Pod documented
22 4 my ( $module, $options, $name ) = @_;
23 4 ▶ my %args = %{ $options // {} };
Condition100%2/2
$options // {}
l!l
22
MC/DC100%1/1
$options // {}
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
24 4 ▶ my $checks = delete( $args{checks} ) // \@Pod::Coverage::More::CHECKS;
Condition100%2/2
delete $args{"checks"} // \@Pod::Coverage::More::CHECKS
l!l
22
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 4 ▶ $name //= "POD coverage of $module";
Condition100%2/2
$name //= "POD coverage of $module"
l!l
13
MC/DC100%1/1
$name //= "POD coverage of $module"
$name
Truth table100%2/2
A
A= $name
Aresult
11
00
26  
27 4 my $pc = Pod::Coverage::More->new( package => $module, %args );
28 4 my $rating = $pc->coverage;
29 4 my @failures;
30 4 ▶ if ( !defined $rating ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $rating) { } 0 4 4
elsif ($rating < 1) { } 0 4 4
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 4 ▶ my $report = $pc->coverage_report // {};
Condition50%1/2
$pc->coverage_report // {}
l!l
40
MC/DC0%0/1
$pc->coverage_report // {}
$pc->coverage_report
Truth table50%1/2
A
A= $pc->coverage_report
Aresult
11
00
39 4 foreach my $sub ( sort keys %$report ) {
40 42 foreach my $check (@$checks) {
41 30 ▶ push @failures, map { "$module: $_" } @{ $report->{$sub}{failures}{$check} || [] };
Condition50%1/2
$report->{$sub}{'failures'}{$check} || []
l!l
300
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 4 my $ok = $TEST->ok( !@failures, $name );
46 4 foreach my $failure (@failures) {
47 1 $TEST->diag($failure);
48 }
49 4 return $ok;
50 }
51  
52  
53 1 ▶sub all_pod_coverage_more_ok {
Subroutine all_pod_coverage_more_ok: called CC=4 SCAR=14.1
Pod documented
54 1 my ($options) = @_;
55 1 my @modules = Test::Pod::Coverage::all_modules();
56 1 ▶ $TEST->plan( tests => scalar @modules ) if !$TEST->has_plan;
Branch: 1 branch
BranchTrueFalseTotal
unless $Test::Pod::Coverage::More::TEST->has_plan 1 0 1
57 1 my $ok = 1;
58 1 foreach my $module (@modules) {
59 1 ▶ $ok = 0 if !pod_coverage_more_ok( $module, $options );
Branch: 1 branch
BranchTrueFalseTotal
unless pod_coverage_more_ok($module, $options) 0 1 1
60 }
61 1 return $ok;
62 }
63  
64 2 1;
65  
66 __END__
« Pod/Coverage/More/Declared/MOP.pm ↑ Summary Pod/Coverage/More/Generator.pm »