| 1 | package Test2::Compare::Delta; | ||||||||||||||||||||||||||||
| 2 | 176 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 176 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 176 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 176 | ▶ | use Test2::Util::HashBase qw{verified id got chk children dne exception note}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 176 | ▶ | use Test2::EventFacet::Info::Table; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 176 | ▶ | use Test2::Util::Table(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 176 | ▶ | use Test2::API qw/context/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 176 | ▶ | use Test2::Util::Ref qw/render_ref rtype/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 176 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # 'CHECK' constant would not work, but I like exposing 'check()' to people | ||||||||||||||||||||||||||||
| 18 | # using this class. | ||||||||||||||||||||||||||||
| 19 | 176 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 176 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 176 | *check = \&chk; | |||||||||||||||||||||||||||
| 22 | 176 | *set_check = \&set_chk; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 176 | my @COLUMN_ORDER = qw/PATH GLNs GOT OP CHECK CLNs/; | |||||||||||||||||||||||||||
| 26 | my %COLUMNS = ( | ||||||||||||||||||||||||||||
| 27 | 332 | ▶ | GOT => {name => 'GOT', value => sub { $_[0]->render_got }, no_collapse => 1}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 332 | ▶ | CHECK => {name => 'CHECK', value => sub { $_[0]->render_check }, no_collapse => 1}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 332 | ▶ | OP => {name => 'OP', value => sub { $_[0]->table_op } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 332 | ▶ | PATH => {name => 'PATH', value => sub { $_[1] } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 332 | ▶ | 'GLNs' => {name => 'GLNs', alias => 'LNs', value => sub { $_[0]->table_got_lines } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 332 | ▶ | 'CLNs' => {name => 'CLNs', alias => 'LNs', value => sub { $_[0]->table_check_lines }}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 176 | ); | |||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||
| 36 | 176 | my $i = 0; | |||||||||||||||||||||||||||
| 37 | 176 | $COLUMNS{$_}->{id} = $i++ for @COLUMN_ORDER; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 5 | ▶ | sub remove_column { | ||||||||||||||||||||||||||
|
Subroutine
remove_column: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 5 | my $class = shift; | |||||||||||||||||||||||||||
| 42 | 5 | my $header = shift; | |||||||||||||||||||||||||||
| 43 | 5 | @COLUMN_ORDER = grep { $_ ne $header } @COLUMN_ORDER; | |||||||||||||||||||||||||||
| 44 | 5 | ▶ | delete $COLUMNS{$header} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 8 | ▶ | sub add_column { | ||||||||||||||||||||||||||
|
Subroutine
add_column: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 8 | my $class = shift; | |||||||||||||||||||||||||||
| 49 | 8 | my $name = shift; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 8 | ▶ | croak "Column name is required" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | unless $name; | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | croak "Column '$name' is already defined" | ||||||||||||||||||||||||||||
| 55 | 7 | ▶ | if $COLUMNS{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 6 | my %params; | |||||||||||||||||||||||||||
| 58 | 6 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 4 | %params = (value => @_, name => $name); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||
| 62 | 2 | %params = (@_, name => $name); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 6 | my $value = $params{value}; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 6 | ▶ | croak "You must specify a 'value' callback" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | unless $value; | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 5 | ▶ | croak "'value' callback must be a CODE reference" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | unless rtype($value) eq 'CODE'; | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 4 | ▶ | if ($params{prefix}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 1 | unshift @COLUMN_ORDER => $name; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | else { | ||||||||||||||||||||||||||||
| 77 | 3 | push @COLUMN_ORDER => $name; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 4 | $COLUMNS{$name} = \%params; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 5 | ▶ | sub set_column_alias { | ||||||||||||||||||||||||||
|
Subroutine
set_column_alias: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 5 | my ($class, $name, $alias) = @_; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | croak "Tried to alias a non-existent column" | ||||||||||||||||||||||||||||
| 87 | 5 | ▶ | unless exists $COLUMNS{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 4 | ▶ | croak "Missing alias" unless defined $alias; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 3 | $COLUMNS{$name}->{alias} = $alias; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 2500 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 2500 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | croak "Cannot specify both 'check' and 'chk' as arguments" | ||||||||||||||||||||||||||||
| 98 | 2500 | ▶ | if exists($self->{check}) && exists($self->{+CHK}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $self->{"check"} and exists $self->{"chk"}
MC/DC100%2/2
exists $self->{"check"} and exists $self->{"chk"}
exists $self->{"check"}
exists $self->{"chk"}
Truth table100%3/3
A and B
A= exists $self->{"check"}B= exists $self->{"chk"}
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | # Allow 'check' as an argument | ||||||||||||||||||||||||||||
| 101 | $self->{+CHK} ||= delete $self->{check} | ||||||||||||||||||||||||||||
| 102 | 2499 | ▶ | if exists $self->{check}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"chk"} ||= delete $self->{"check"}
MC/DC50%1/2
$self->{"chk"} ||= delete $self->{"check"}
$self->{"chk"}
delete $self->{"check"}
Truth table66%2/3
A ||= B
A= $self->{"chk"}B= delete $self->{"check"}
| |||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 336 | ▶ | sub render_got { | ||||||||||||||||||||||||||
|
Subroutine
render_got: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 336 | my $self = shift; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 336 | my $exp = $self->{+EXCEPTION}; | |||||||||||||||||||||||||||
| 109 | 336 | ▶ | if ($exp) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 1 | chomp($exp = "$exp"); | |||||||||||||||||||||||||||
| 111 | 1 | $exp =~ s/\n.*$//g; | |||||||||||||||||||||||||||
| 112 | 1 | return "<EXCEPTION: $exp>"; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 335 | my $dne = $self->{+DNE}; | |||||||||||||||||||||||||||
| 116 | 335 | ▶ | return '<DOES NOT EXIST>' if $dne && $dne eq 'got'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$dne and $dne eq "got"
MC/DC100%2/2
$dne and $dne eq "got"
$dne
$dne eq "got"
Truth table100%3/3
A and B
A= $dneB= $dne eq "got"
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 314 | my $got = $self->{+GOT}; | |||||||||||||||||||||||||||
| 119 | 314 | ▶ | return '<UNDEF>' unless defined $got; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 299 | my $check = $self->{+CHK}; | |||||||||||||||||||||||||||
| 122 | 299 | ▶ | my $stringify = defined( $check ) && $check->stringify_got; | ||||||||||||||||||||||||||
|
Condition100%3/3
defined $check && $check->stringify_got
MC/DC100%2/2
defined $check && $check->stringify_got
defined $check
$check->stringify_got
Truth table100%3/3
A && B
A= defined $checkB= $check->stringify_got
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 299 | ▶ | return render_ref($got) if ref $got && !$stringify; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $got and not $stringify
MC/DC100%2/2
ref $got and not $stringify
ref $got
not $stringify
Truth table100%3/3
A and not(B)
A= ref $gotB= not $stringify
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 233 | return "$got"; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 334 | ▶ | sub render_check { | ||||||||||||||||||||||||||
|
Subroutine
render_check: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 130 | 334 | my $self = shift; | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 334 | my $dne = $self->{+DNE}; | |||||||||||||||||||||||||||
| 133 | 334 | ▶ | return '<DOES NOT EXIST>' if $dne && $dne eq 'check'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$dne and $dne eq "check"
MC/DC100%2/2
$dne and $dne eq "check"
$dne
$dne eq "check"
Truth table100%3/3
A and B
A= $dneB= $dne eq "check"
| |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 320 | my $check = $self->{+CHK}; | |||||||||||||||||||||||||||
| 136 | 320 | ▶ | return '<UNDEF>' unless defined $check; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 318 | return $check->render; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 171 | ▶ | sub _full_id { | ||||||||||||||||||||||||||
|
Subroutine
_full_id: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 142 | 171 | my ($type, $id) = @_; | |||||||||||||||||||||||||||
| 143 | 171 | ▶ | return "<$id>" if !$type || $type eq 'META'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $type or $type eq "META"
MC/DC100%2/2
not $type or $type eq "META"
not $type
$type eq "META"
Truth table100%3/3
not(A) or B
A= not $typeB= $type eq "META"
| |||||||||||||||||||||||||||||
| 144 | 134 | ▶ | return $id if $type eq 'SCALAR'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 125 | ▶ | return "{$id}" if $type eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 82 | ▶ | return "{$id} <KEY>" if $type eq 'HASHKEY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 79 | ▶ | return "[$id]" if $type eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 19 | ▶ | return "$id()" if $type eq 'METHOD'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 2 | ▶ | return "$id" if $type eq 'DEREF'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | return "<$id>"; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 180 | ▶ | sub _arrow_id { | ||||||||||||||||||||||||||
|
Subroutine
_arrow_id: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||
| 154 | 180 | my ($path, $type) = @_; | |||||||||||||||||||||||||||
| 155 | 180 | ▶ | return '' unless $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 65 | ▶ | return ' ' if !$type || $type eq 'META'; # Meta gets a space, not an arrow | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $type or $type eq "META"
MC/DC100%2/2
not $type or $type eq "META"
not $type
$type eq "META"
Truth table100%3/3
not(A) or B
A= not $typeB= $type eq "META"
| |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 50 | ▶ | return '->' if $type eq 'METHOD'; # Method always needs an arrow | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 43 | ▶ | return '->' if $type eq 'SCALAR'; # Scalar always needs an arrow | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 36 | ▶ | return '->' if $type eq 'DEREF'; # deref always needs arrow | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 35 | ▶ | return '->' if $path =~ m/(>|\(\))$/; # Need an arrow after meta, or after a method | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 29 | ▶ | return '->' if $path eq '$VAR'; # Need an arrow after the initial ref | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | # Hash and array need an arrow unless they follow another hash/array | ||||||||||||||||||||||||||||
| 166 | 26 | ▶ | return '->' if $type =~ m/^(HASH|ARRAY)$/ && $path !~ m/(\]|\})$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type =~ /^(HASH|ARRAY)$/ and not $path =~ /(\]|\})$/
MC/DC50%1/2
$type =~ /^(HASH|ARRAY)$/ and not $path =~ /(\]|\})$/
$type =~ /^(HASH|ARRAY)$/
not $path =~ /(\]|\})$/
Truth table66%2/3
A and not(B)
A= $type =~ /^(HASH|ARRAY)$/B= not $path =~ /(\]|\})$/
| |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | # No arrow needed | ||||||||||||||||||||||||||||
| 169 | 21 | return ''; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 165 | ▶ | sub _join_id { | ||||||||||||||||||||||||||
|
Subroutine
_join_id: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 173 | 165 | my ($path, $parts) = @_; | |||||||||||||||||||||||||||
| 174 | 165 | my ($type, $key) = @$parts; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 165 | my $id = _full_id($type, $key); | |||||||||||||||||||||||||||
| 177 | 165 | my $join = _arrow_id($path, $type); | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 165 | return "${path}${join}${id}"; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 363 | ▶ | sub should_show { | ||||||||||||||||||||||||||
|
Subroutine
should_show: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 363 | my $self = shift; | |||||||||||||||||||||||||||
| 184 | 363 | ▶ | return 1 unless $self->verified; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 77 | ▶ | defined( my $check = $self->check ) || return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 74 | ▶ | return 0 unless $check->lines; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 74 | ▶ | my $file = $check->file || return 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$check->file || (return 0)
MC/DC100%1/1
$check->file || (return 0)
$check->file
Truth table100%2/2
A
A= $check->file
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 50 | my $ctx = context(); | |||||||||||||||||||||||||||
| 190 | 50 | my $cfile = $ctx->trace->file; | |||||||||||||||||||||||||||
| 191 | 50 | $ctx->release; | |||||||||||||||||||||||||||
| 192 | 50 | ▶ | return 0 unless $file eq $cfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 49 | return 1; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 234 | ▶ | sub filter_visible { | ||||||||||||||||||||||||||
|
Subroutine
filter_visible: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 234 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 234 | my @deltas; | |||||||||||||||||||||||||||
| 201 | 234 | my @queue = (['', $self]); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 234 | ▶ | while (my $set = shift @queue) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 357 | my ($path, $delta) = @$set; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 357 | ▶ | push @deltas => [$path, $delta] if $delta->should_show; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 357 | ▶ | my $children = $delta->children || next; | ||||||||||||||||||||||||||
|
Condition100%2/2
$delta->children || (next)
MC/DC100%1/1
$delta->children || (next)
$delta->children
Truth table100%2/2
A
A= $delta->children
| |||||||||||||||||||||||||||||
| 209 | 332 | ▶ | next unless @$children; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 72 | my @new; | |||||||||||||||||||||||||||
| 212 | 72 | for my $child (@$children) { | |||||||||||||||||||||||||||
| 213 | 123 | my $cpath = _join_id($path, $child->id); | |||||||||||||||||||||||||||
| 214 | 123 | push @new => [$cpath, $child]; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | 72 | unshift @queue => @new; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 234 | return \@deltas; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 240 | ▶ | sub table_header { [map {$COLUMNS{$_}->{alias} || $_} @COLUMN_ORDER] } | ||||||||||||||||||||||||||
|
Subroutine
table_header: called CC=2 SCAR=7.1
Pod
documented
Condition66%2/3
$COLUMNS{$_}{'alias'} || $_
MC/DC0%0/2
$COLUMNS{$_}{'alias'} || $_
$COLUMNS{$_}{'alias'}
$_
Truth table66%2/3
A || B
A= $COLUMNS{$_}{'alias'}B= $_
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 334 | ▶ | sub table_op { | ||||||||||||||||||||||||||
|
Subroutine
table_op: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 225 | 334 | my $self = shift; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 334 | ▶ | defined( my $check = $self->{+CHK} ) || return '!exists'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | return $check->operator($self->{+GOT}) | ||||||||||||||||||||||||||||
| 230 | 320 | ▶ | unless $self->{+DNE} && $self->{+DNE} eq 'got'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"dne"} and $self->{"dne"} eq "got"
MC/DC100%2/2
$self->{"dne"} and $self->{"dne"} eq "got"
$self->{"dne"}
$self->{"dne"} eq "got"
Truth table100%3/3
A and B
A= $self->{"dne"}B= $self->{"dne"} eq "got"
| |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 21 | return $check->operator(); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 334 | ▶ | sub table_check_lines { | ||||||||||||||||||||||||||
|
Subroutine
table_check_lines: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 334 | my $self = shift; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 334 | ▶ | defined( my $check = $self->{+CHK} ) || return ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 320 | ▶ | my $lines = $check->lines || return ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$check->lines || (return '')
MC/DC0%0/1
$check->lines || (return '')
$check->lines
Truth table50%1/2
A
A= $check->lines
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 320 | ▶ | return '' unless @$lines; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 279 | return join ', ' => @$lines; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 335 | ▶ | sub table_got_lines { | ||||||||||||||||||||||||||
|
Subroutine
table_got_lines: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 247 | 335 | my $self = shift; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 335 | ▶ | defined( my $check = $self->{+CHK} ) || return ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 321 | ▶ | return '' if $self->{+DNE} && $self->{+DNE} eq 'got'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"dne"} and $self->{"dne"} eq "got"
MC/DC100%2/2
$self->{"dne"} and $self->{"dne"} eq "got"
$self->{"dne"}
$self->{"dne"} eq "got"
Truth table100%3/3
A and B
A= $self->{"dne"}B= $self->{"dne"} eq "got"
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 300 | my @lines = $check->got_lines($self->{+GOT}); | |||||||||||||||||||||||||||
| 253 | 300 | ▶ | return '' unless @lines; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 5 | return join ', ' => @lines; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 234 | ▶ | sub table_rows { | ||||||||||||||||||||||||||
|
Subroutine
table_rows: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 259 | 234 | my $self = shift; | |||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 234 | my $deltas = $self->filter_visible; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 234 | my @rows; | |||||||||||||||||||||||||||
| 264 | 234 | for my $set (@$deltas) { | |||||||||||||||||||||||||||
| 265 | 332 | my ($id, $d) = @$set; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 332 | my @row; | |||||||||||||||||||||||||||
| 268 | 332 | for my $col (@COLUMN_ORDER) { | |||||||||||||||||||||||||||
| 269 | 2005 | my $spec = $COLUMNS{$col}; | |||||||||||||||||||||||||||
| 270 | 2005 | my $val = $spec->{value}->($d, $id); | |||||||||||||||||||||||||||
| 271 | 2005 | ▶ | $val = '' unless defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 2005 | push @row => $val; | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 332 | push @rows => \@row; | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 234 | return \@rows; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 236 | ▶ | sub table { | ||||||||||||||||||||||||||
|
Subroutine
table: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 282 | 236 | my $self = shift; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 236 | my @diag; | |||||||||||||||||||||||||||
| 285 | 236 | my $header = $self->table_header; | |||||||||||||||||||||||||||
| 286 | 236 | my $rows = $self->table_rows; | |||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 236 | my $render_rows = [@$rows]; | |||||||||||||||||||||||||||
| 289 | 236 | ▶ | my $max = exists $ENV{TS_MAX_DELTA} ? $ENV{TS_MAX_DELTA} : 25; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 236 | ▶ | if ($max && @$render_rows > $max) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$max and @$render_rows > $max
MC/DC50%1/2
$max and @$render_rows > $max
$max
@$render_rows > $max
Truth table66%2/3
A and B
A= $maxB= @$render_rows > $max
| |||||||||||||||||||||||||||||
| 291 | 1 | @$render_rows = map { [@$_] } @{$render_rows}[0 .. ($max - 1)]; | |||||||||||||||||||||||||||
| 292 | 1 | @diag = ( | |||||||||||||||||||||||||||
| 293 | "************************************************************", | ||||||||||||||||||||||||||||
| 294 | sprintf("* Stopped after %-42.42s *", "$max differences."), | ||||||||||||||||||||||||||||
| 295 | "* Set the TS_MAX_DELTA environment var to raise the limit. *", | ||||||||||||||||||||||||||||
| 296 | "* Set it to 0 for no limit. *", | ||||||||||||||||||||||||||||
| 297 | "************************************************************", | ||||||||||||||||||||||||||||
| 298 | ); | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 236 | my @dne; | |||||||||||||||||||||||||||
| 302 | 236 | for my $row (@$render_rows) { | |||||||||||||||||||||||||||
| 303 | 340 | ▶ | my $got = $row->[$COLUMNS{GOT}->{id}] || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$$row[$COLUMNS{'GOT'}{'id'}] || ''
MC/DC100%1/1
$$row[$COLUMNS{'GOT'}{'id'}] || ''
$$row[$COLUMNS{'GOT'}{'id'}]
Truth table100%2/2
A
A= $$row[$COLUMNS{'GOT'}{'id'}]
| |||||||||||||||||||||||||||||
| 304 | 340 | ▶ | my $chk = $row->[$COLUMNS{CHECK}->{id}] || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$$row[$COLUMNS{'CHECK'}{'id'}] || ''
MC/DC100%1/1
$$row[$COLUMNS{'CHECK'}{'id'}] || ''
$$row[$COLUMNS{'CHECK'}{'id'}]
Truth table100%2/2
A
A= $$row[$COLUMNS{'CHECK'}{'id'}]
| |||||||||||||||||||||||||||||
| 305 | 340 | ▶ | if ($got eq '<DOES NOT EXIST>') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 306 | 20 | push @dne => "$row->[$COLUMNS{PATH}->{id}]: DOES NOT EXIST"; | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | elsif ($chk eq '<DOES NOT EXIST>') { | ||||||||||||||||||||||||||||
| 309 | 15 | push @dne => "$row->[$COLUMNS{PATH}->{id}]: SHOULD NOT EXIST"; | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 236 | ▶ | if (@dne) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | 25 | unshift @dne => '==== Summary of missing/extra items ===='; | |||||||||||||||||||||||||||
| 315 | 25 | push @dne => '== end summary of missing/extra items =='; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | my $table_args = { | ||||||||||||||||||||||||||||
| 319 | header => $header, | ||||||||||||||||||||||||||||
| 320 | collapse => 1, | ||||||||||||||||||||||||||||
| 321 | sanitize => 1, | ||||||||||||||||||||||||||||
| 322 | mark_tail => 1, | ||||||||||||||||||||||||||||
| 323 | 236 | no_collapse => [grep { $COLUMNS{$COLUMN_ORDER[$_]}->{no_collapse} } 0 .. $#COLUMN_ORDER], | |||||||||||||||||||||||||||
| 324 | }; | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 236 | my $render = join "\n" => ( | |||||||||||||||||||||||||||
| 327 | Test2::Util::Table::table(%$table_args, rows => $render_rows), | ||||||||||||||||||||||||||||
| 328 | @dne, | ||||||||||||||||||||||||||||
| 329 | @diag, | ||||||||||||||||||||||||||||
| 330 | ); | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 236 | my $table = Test2::EventFacet::Info::Table->new( | |||||||||||||||||||||||||||
| 333 | %$table_args, | ||||||||||||||||||||||||||||
| 334 | rows => $rows, | ||||||||||||||||||||||||||||
| 335 | as_string => $render, | ||||||||||||||||||||||||||||
| 336 | ); | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 236 | return $table; | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 228 | ▶ | sub diag { shift->table } | ||||||||||||||||||||||||||
|
Subroutine
diag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 176 | 1; | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | __END__ | ||||||||||||||||||||||||||||