blib/lib/Test/Deep/YAML.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 2 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 91.6% 55 / 60 CC 4 SCAR 4.3
CC
4
Cov
95%
descend
3.0
diagnostics
2.0
BEGIN
1.0
CRAP 1.5
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Test::Deep::YAML; # git description: v0.003-2-g42e13ef
4 # ABSTRACT: A Test::Deep plugin for comparing YAML-encoded data
5 # KEYWORDS: testing tests plugin YAML data
6 # vim: set ts=8 sts=4 sw=4 tw=78 et :
7  
8 1 our $VERSION = '0.004';
9  
10 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @EXPORT = qw(yaml);
13  
14 sub yaml
15 9 ▶{
Subroutine yaml: called CC=1 SCAR=0.0
Pod documented
16 9 my ($expected) = @_;
17 9 return Test::Deep::YAML::Object->new($expected);
18 }
19  
20 package # hide from PAUSE
21 Test::Deep::YAML::Object;
22  
23 1 our $VERSION = '0.004';
24  
25 1 ▶use parent 'Test::Deep::Cmp';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Try::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use YAML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 sub init
30 9 ▶{
Subroutine init: called CC=1 SCAR=0.0
31 9 my ($self, $expected) = @_;
32 9 $self->{val} = $expected;
33 }
34  
35 sub descend
36 9 ▶{
Subroutine descend: called CC=3 SCAR=11.0
37 9 my ($self, $got) = @_;
38  
39 my $data = Try::Tiny::try
40 9 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 9 YAML::Load($got);
42 }
43 Try::Tiny::catch
44 1 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
45 1 chomp($self->{error_message} = $_);
46 1 undef;
47 9 };
48  
49 9 ▶ return 0 if not $data or $self->{error_message};
Branch: 1 branch
BranchTrueFalseTotal
if not $data or $self->{"error_message"} 1 8 9
Condition66%2/3
not $data or $self->{"error_message"}
l!l&&r!l&&!r
108
MC/DC50%1/2
not $data or $self->{"error_message"}
not $data $self->{"error_message"}
Truth table66%2/3
not(A) or B
A= not $dataB= $self->{"error_message"}
ABresult
1X1
011
000
50  
51 8 return Test::Deep::wrap($self->{val})->descend($data);
52 }
53  
54 sub diagnostics
55 2 ▶{
Subroutine diagnostics: called CC=2 SCAR=7.1
56 2 my ($self, $where, $last) = @_;
57 return $self->{error_message}
58 2 ▶ || $self->{val}->diagnostics($where, $last);
Condition66%2/3
$self->{'error_message'} || $self->{'val'}->diagnostics($where, $last)
l!l&&r!l&&!r
110
MC/DC0%0/2
$self->{'error_message'} || $self->{'val'}->diagnostics($where, $last)
$self->{'error_message'} $self->{'val'}->diagnostics($where, $last)
Truth table66%2/3
A || B
A= $self->{'error_message'}B= $self->{'val'}->diagnostics($where, $last)
ABresult
1X1
011
000
59 }
60  
61 1 1;
62  
63 __END__
↑ Summary