| 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.41.1'; # TRIAL 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
| |||||||||||||||||||||||||||||
| 33 | 242 | $yaml .= $token->{value}; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 248 | ▶ | $column = '???' unless defined $column; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 248 | my $remaining_yaml = $self->{yaml}; | |||||||||||||||||||||||||||
| 38 | 248 | ▶ | $remaining_yaml = '' unless defined $remaining_yaml; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$self->{"got"} and $self->{"expected"}
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"}
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||