Test/Config/IOD.pm

filter: Statementstmt 100% 44 / 44 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 94.1% 64 / 68 CC 6 SCAR 7.3
CC
6
Cov
94%
__ANON__
4.0
test_modify_doc
3.0
__ANON__
1.0
CRAP 2.1
« Config/IOD/Document.pm ↑ Summary Config/IOD/Constants.pm »
1 package Test::Config::IOD;
2  
3 ## no critic (Modules::ProhibitAutomaticExportation)
4  
5 7 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 ▶use Test::Differences;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use Test::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Config::IOD;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 7 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 7 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
17 7 our $DATE = '2022-05-02'; # DATE
18 7 our $DIST = 'Config-IOD'; # DIST
19 7 our $VERSION = '0.353'; # VERSION
20  
21 7 our @EXPORT = qw(test_modify_doc);
22  
23 49 ▶sub test_modify_doc {
Subroutine test_modify_doc: called CC=3 SCAR=11.0
Pod documented
24 49 my $opts;
25 49 ▶ if (ref($_[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 18 31 49
26 18 $opts = shift;
27 } else {
28 31 $opts = {};
29 }
30 49 my ($code, $doc1, $doc2, $name) = @_;
31  
32 49 ▶ subtest +($name // "test_modify_doc") => sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
33 49 my $iod = Config::IOD->new;
34 49 my $doc = $iod->read_string($doc1);
35 49 ▶ if ($opts->{dies}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'dies'}) { } 18 31 49
36 18 ▶ dies_ok { $code->($doc) } "dies"
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
&dies_ok(sub { &$code($doc); } , "dies") or return 0 18 0 18
37 or return 0;
38 18 return 1;
39 } else {
40 31 ▶ lives_ok { $code->($doc) } "lives"
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
&lives_ok(sub { &$code($doc); } , "lives") or return 0 31 0 31
41 or return 0;
42 }
43 31 eq_or_diff $doc->as_string, $doc2, "result";
44 49 ▶ };
Condition50%1/2
$name // "test_modify_doc"
l!l
490
MC/DC0%0/1
$name // "test_modify_doc"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
45 }
46  
47 7 1;
48 # ABSTRACT: Testing routines for Config::IOD
49  
50 __END__
« Config/IOD/Document.pm ↑ Summary Config/IOD/Constants.pm »