blib/lib/YAML/PP/Exception.pm

filter: Statementstmt 100% 45 / 45 Branchbran 75.0% 6 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 90.7% 59 / 65 CC 7 SCAR 15.7
CC
7
Cov
95%
to_string
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
« blib/lib/YAML/PP/Schema/YAML1_1.pm ↑ Summary blib/lib/YAML/PP/Schema/JSON.pm »
1 52 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 52 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package YAML::PP::Exception;
4  
5 52 our $VERSION = 'v0.43.0'; # VERSION
6  
7 52 ▶use overload '""' => \&to_string;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 124 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 124 my ($class, %args) = @_;
11 my $self = bless {
12 line => $args{line},
13 msg => $args{msg},
14 next => $args{next},
15 where => $args{where},
16 yaml => $args{yaml},
17 got => $args{got},
18 expected => $args{expected},
19 column => $args{column},
20 124 }, $class;
21 124 return $self;
22 }
23  
24 248 ▶sub to_string {
Subroutine to_string: called CC=7 SCAR=19.5
Pod undocumented
25 248 my ($self) = @_;
26 248 my $next = $self->{next};
27 248 my $line = $self->{line};
28 248 my $column = $self->{column};
29  
30 248 my $yaml = '';
31 248 for my $token (@$next) {
32 286 ▶ last if $token->{name} eq 'EOL';
Branch: 1 branch
BranchTrueFalseTotal
if $token->{"name"} eq "EOL" 44 242 286
33 242 $yaml .= $token->{value};
34 }
35 248 ▶ $column = '???' unless defined $column;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $column 0 248 248
36  
37 248 my $remaining_yaml = $self->{yaml};
38 248 ▶ $remaining_yaml = '' unless defined $remaining_yaml;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $remaining_yaml 0 248 248
39 248 $yaml .= $remaining_yaml;
40 {
41 248 local $@; # avoid bug in old Data::Dumper
42 248 require Data::Dumper;
43 248 local $Data::Dumper::Useqq = 1;
44 248 local $Data::Dumper::Terse = 1;
45 248 $yaml = Data::Dumper->Dump([$yaml], ['yaml']);
46 248 chomp $yaml;
47 }
48  
49 248 my $lines = 5;
50 248 my @fields;
51  
52 248 ▶ if ($self->{got} and $self->{expected}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'got'} and $self->{'expected'}) { } 96 152 248
Condition66%2/3
$self->{"got"} and $self->{"expected"}
!ll&&!rl&&r
152096
MC/DC50%1/2
$self->{"got"} and $self->{"expected"}
$self->{"got"} $self->{"expected"}
Truth table66%2/3
A and B
A= $self->{"got"}B= $self->{"expected"}
ABresult
0X0
100
111
53 96 $lines = 6;
54 96 $line = $self->{got}->{line};
55 96 $column = $self->{got}->{column} + 1;
56 @fields = (
57 "Line" => $line,
58 "Column" => $column,
59 96 "Expected", join(" ", @{ $self->{expected} }),
60 "Got", $self->{got}->{name},
61 "Where", $self->{where},
62 96 "YAML", $yaml,
63 );
64 }
65 else {
66 @fields = (
67 "Line" => $line,
68 "Column" => $column,
69 "Message", $self->{msg},
70 "Where", $self->{where},
71 152 "YAML", $yaml,
72 );
73 }
74 248 my $fmt = join "\n", ("%-10s: %s") x $lines;
75 248 my $string = sprintf $fmt, @fields;
76 248 return $string;
77 }
78  
79 52 1;
« blib/lib/YAML/PP/Schema/YAML1_1.pm ↑ Summary blib/lib/YAML/PP/Schema/JSON.pm »