blib/lib/Devel/Cover/Report/XSCover.pm

filter: Statementstmt 91.8% 306 / 333 Branchbran 84.1% 143 / 170 Conditioncond 73.4% 58 / 79 MC/DCmcdc 48.8% 22 / 45 Subroutinesub 100% 28 / 28 Podpod 100% 2 / 2 totaltotal 85.0% 559 / 657 CC 285 SCAR 33.1
CC
285
Cov
87%
_cell
63.7
_cell
52.7
_write_file_page
31.9
CRAP 27.5
↑ Summary blib/lib/Devel/XSCover/DB.pm »
1 package Devel::Cover::Report::XSCover;
2  
3 16 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 16 our $VERSION = '0.09';
12  
13 16 our (%LABEL, %SHORT, %COLUMN, $THRESHOLD);
14  
15 32 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
16 16 %LABEL = (
17 statement => 'statements',
18 branch => 'branches',
19 condition => 'conditions',
20 subroutine => 'subroutines',
21 pod => 'pod',
22 time => 'time',
23 total => 'total',
24 );
25 16 %SHORT = (statement => 'stmt', branch => 'bran', condition => 'cond', subroutine => 'sub', pod => 'pod', time => 'time', total => 'total');
26 16 %COLUMN = (statement => 'st', branch => 'br', condition => 'cd', subroutine => 'sb', pod => 'pd', time => 'tm');
27 16 $THRESHOLD = { c0 => 75, c1 => 90, c2 => 100 };
28 }
29  
30 52 ▶sub get_options {
Subroutine get_options: called CC=3 SCAR=11.0
Pod documented
31 26 my ($self, $opt) = @_;
32 26 $opt->{option}{outputfile} = 'coverage.html';
33 26 $opt->{option}{summarytitle} = 'Coverage summary';
34 26 $THRESHOLD->{$_} = $opt->{"report_$_"} for grep { defined $opt->{"report_$_"} } qw(c0 c1 c2);
35 26 ▶ die "Invalid command line options" unless Getopt::Long::GetOptions($opt->{option}, qw(outputfile=s summarytitle=s report_c0=s report_c1=s report_c2=s));
Branch: 1 branch
BranchTrueFalseTotal
unless &Getopt::Long::GetOptions($opt->{"option"}, ("outputfile=s", "summarytitle=s", "report_c0=s", "report_c1=s", "report_c2=s")) 2 42 44
36 }
37  
38 26 ▶sub report {
Subroutine report: called CC=3 SCAR=11.0
Pod documented
39 13 my ($class, $db, $opt) = @_;
40 13 my @files = grep { $db->{summary}{$_} } @{ $opt->{file} };
41 13 my %page = map { $_ => _page_name($_) } @files;
42 13 my @show = grep { $opt->{show}{$_} } $db->criteria;
43 13 my %xs = _xs_partners(\@files);
44 13 for my $file (@files) {
45 38 _write_file_page($db, $opt, $file, \@show, \%page, \%xs);
46 }
47 13 _write_summary_page($db, $opt, \@files, \@show, \%page, \%xs);
48 13 ▶ print "done.\n" unless $opt->{silent};
Branch: 1 branch
BranchTrueFalseTotal
unless $opt->{"silent"} 125 59 184
49 }
50  
51 76 ▶sub _page_name {
Subroutine _page_name: called CC=1 SCAR=0.0
52 38 my ($file) = @_;
53 38 (my $name = $file) =~ s/\W/-/g;
54 38 return "$name.html";
55 }
56  
57 26 ▶sub _xs_partners {
Subroutine _xs_partners: called CC=7 SCAR=19.7
58 13 my ($files) = @_;
59 13 my (%pm, %xs);
60 13 for my $f (@$files) {
61 38 ▶ my ($stem) = $f =~ m{([^/\\]+)\.(?:pm|xs)\z} or next;
Branch: 1 branch
BranchTrueFalseTotal
my($stem) = $f =~ m(([^/\\]+)\.(?:pm|xs)\z)u or next 18 30 48
62 18 ▶ my $slot = $f =~ /\.pm\z/ ? \%pm : \%xs;
Branch: 1 branch
BranchTrueFalseTotal
$f =~ /\.pm\z/u ? : 13 16 29
63 18 push @{ $slot->{$stem} }, $f;
64 }
65 13 my %partner;
66 13 for my $stem (keys %pm) {
67 2 ▶ next unless $xs{$stem};
Branch: 1 branch
BranchTrueFalseTotal
unless $xs{$stem} 4 10 14
68 0 for my $pm (@{ $pm{$stem} }) {
69 0 $partner{$pm} = $xs{$stem};
70 }
71 }
72 13 return %partner;
73 }
74  
75 428 ▶sub _pclass {
Subroutine _pclass: called CC=5 SCAR=16.1
76 214 my ($pc, $error) = @_;
77 214 ▶ return 'c3' unless $error;
Branch: 1 branch
BranchTrueFalseTotal
unless $error 59 197 256
78 156 ▶ return 'c0' if $pc < $THRESHOLD->{c0};
Branch: 1 branch
BranchTrueFalseTotal
if $pc < $Devel::Cover::Report::XSCover::THRESHOLD->{"c0"} 74 119 193
79 116 ▶ return 'c1' if $pc < $THRESHOLD->{c1};
Branch: 1 branch
BranchTrueFalseTotal
if $pc < $Devel::Cover::Report::XSCover::THRESHOLD->{"c1"} 85 126 211
80 33 ▶ return 'c2' if $pc < $THRESHOLD->{c2};
Branch: 1 branch
BranchTrueFalseTotal
if $pc < $Devel::Cover::Report::XSCover::THRESHOLD->{"c2"} 19 3517 3536
81 14 return 'c3';
82 }
83  
84 171 ▶sub _bclass { $_[0] ? 'c3' : 'c0' }
Subroutine _bclass: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 215 1321 1536
85  
86 678 ▶sub _pc {
Subroutine _pc: called CC=1 SCAR=0.0
87 339 my ($value) = @_;
88 339 my $text = sprintf '%.2f', $value;
89 339 chop $text;
90 339 return $text;
91 }
92  
93 5462 ▶sub _escape {
Subroutine _escape: called CC=1 SCAR=0.0
94 2731 my ($text) = @_;
95 2731 $text =~ s/&/&amp;/g;
96 2731 $text =~ s/</&lt;/g;
97 2731 $text =~ s/>/&gt;/g;
98 2731 $text =~ s/"/&quot;/g;
99 2731 $text =~ s/'/&#39;/g;
100 2731 return $text;
101 }
102  
103 366 ▶sub _summary_cell {
Subroutine _summary_cell: called CC=6 SCAR=17.9
104 183 my ($db, $file, $criterion, $extra) = @_;
105 183 my $s = $db->{summary}{$file}{$criterion};
106 183 ▶ my $col = $COLUMN{$criterion} // 'tt';
Condition100%3/3
$Devel::Cover::Report::XSCover::COLUMN{$criterion} // "tt"
l!l
2461403300
MC/DC100%1/1
$Devel::Cover::Report::XSCover::COLUMN{$criterion} // "tt"
$Devel::Cover::Report::XSCover::COLUMN{$criterion}
Truth table100%2/2
A
A= $Devel::Cover::Report::XSCover::COLUMN{$criterion}
Aresult
11
00
107 183 ▶ return qq{<td class="pc na $col" data-v="-1">n/a</td>} unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 15 1533 1548
108 168 my $pc = _pc($s->{percentage});
109 168 my $class = _pclass($s->{percentage}, $s->{error});
110 168 ▶ my $title = sprintf '%s: %d of %d', $LABEL{$criterion}, $s->{covered} || 0, $s->{total} || 0;
Condition100%6/6
$s->{'covered'} || 0
l!l
16648258
$s->{'total'} || 0
l!l
16618101
MC/DC100%1/1
$s->{'covered'} || 0
$s->{'covered'}
MC/DC100%1/1
$s->{'total'} || 0
$s->{'total'}
Truth table100%2/2
A
A= $s->{'covered'}
Aresult
11
00
Truth table100%2/2
A
A= $s->{'total'}
Aresult
11
00
111 168 ▶ $title = $LABEL{$criterion} if $criterion eq 'time';
Branch: 1 branch
BranchTrueFalseTotal
if $criterion eq "time" 94 1439 1533
112 168 return qq{<td class="pc $class $col" data-v="$pc" title="} . _escape($title) . qq{"><meter min="0" max="100" value="$pc"></meter><span>$pc</span></td>};
113 }
114  
115 24 ▶sub _run_meta {
Subroutine _run_meta: called CC=10 SCAR=23.1
116 12 my ($db) = @_;
117 12 my @runs = eval { $db->runs };
118 12 ▶ return '' unless @runs;
Branch: 1 branch
BranchTrueFalseTotal
unless @runs 305 184 489
119 0 my ($start) = sort { $a <=> $b } grep { $_ } map { $_->start } @runs;
120 0 my ($finish) = sort { $b <=> $a } grep { $_ } map { $_->finish } @runs;
121 11 ▶ my ($perl) = grep { defined && length } map { $_->perl } @runs;
Condition100%3/3
defined $_ && length $_
!ll&&!rl&&r
103094
MC/DC50%1/2
defined $_ && length $_
defined $_ length $_
Truth table66%2/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
122 11 ▶ my ($os) = grep { defined && length } map { $_->OS } @runs;
Condition66%2/3
defined $_ && length $_
!ll&&!rl&&r
209
MC/DC50%1/2
defined $_ && length $_
defined $_ length $_
Truth table66%2/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
123 11 my @parts;
124 11 ▶ push @parts, "perl $perl" if $perl;
Branch: 1 branch
BranchTrueFalseTotal
if $perl 13 171 184
125 11 ▶ push @parts, $os if $os;
Branch: 1 branch
BranchTrueFalseTotal
if $os 119 61 180
126 11 ▶ push @parts, POSIX::strftime('%Y-%m-%d %H:%M', localtime $start) . ($finish && $finish > $start ? POSIX::strftime(' to %H:%M', localtime $finish) : '') if $start;
Branch: 2 branches
BranchTrueFalseTotal
if $start 65 5 70
$finish && $finish > $start ? : 46 268 314
Condition66%2/3
$finish and $finish > $start
!ll&&!rl&&r
190
MC/DC0%0/2
$finish and $finish > $start
$finish $finish > $start
Truth table66%2/3
A and B
A= $finishB= $finish > $start
ABresult
0X0
100
111
127 11 ▶ push @parts, scalar(@runs) . ' run' . (@runs == 1 ? '' : 's');
Branch: 1 branch
BranchTrueFalseTotal
@runs == 1 ? : 11 46 57
128 11 return _escape(join ' ยท ', @parts);
129 }
130  
131 26 ▶sub _write_summary_page {
Subroutine _write_summary_page: called CC=16 SCAR=27.8
132 13 my ($db, $opt, $files, $show, $page, $xs) = @_;
133 13 ▶ my $title = $opt->{option}{summarytitle} // 'Coverage summary';
Condition100%2/2
$opt->{"option"}{"summarytitle"} // "Coverage summary"
l!l
121
MC/DC100%1/1
$opt->{"option"}{"summarytitle"} // "Coverage summary"
$opt->{"option"}{"summarytitle"}
Truth table100%2/2
A
A= $opt->{"option"}{"summarytitle"}
Aresult
11
00
134 13 ▶ my $out = File::Spec->catfile($opt->{outputdir}, $opt->{option}{outputfile} // 'coverage.html');
Condition100%2/2
$opt->{"option"}{"outputfile"} // "coverage.html"
l!l
121
MC/DC100%1/1
$opt->{"option"}{"outputfile"} // "coverage.html"
$opt->{"option"}{"outputfile"}
Truth table100%2/2
A
A= $opt->{"option"}{"outputfile"}
Aresult
11
00
135 13 ▶ open my $fh, '>', $out or do { warn "Can't open file '$out' [$!]\n"; return };
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $out or do { warn "Can't open file '${out}' [$!]\n"; return } 28 102 130
136 12 print $fh _head($title, 'summary');
137 12 ▶ print $fh qq{<header><div><h1>} . _escape($title) . qq{</h1><p class="meta">} . _run_meta($db) . qq{ ยท } . scalar(@$files) . qq{ file} . (@$files == 1 ? '' : 's') . qq{</p></div>} . _theme_button() . qq{</header>\n<main>\n};
Branch: 1 branch
BranchTrueFalseTotal
@$files == 1 ? : 2 85 87
138 12 ▶ my $total = $db->{summary}{Total} || {};
Condition100%2/2
$db->{'summary'}{'Total'} || {}
l!l
111
MC/DC100%1/1
$db->{'summary'}{'Total'} || {}
$db->{'summary'}{'Total'}
Truth table100%2/2
A
A= $db->{'summary'}{'Total'}
Aresult
11
00
139 12 print $fh qq{<section class="tiles">\n};
140 12 for my $c (@$show, 'total') {
141 44 my $s = $total->{$c};
142 44 ▶ next unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 50 42 92
143 42 my $class = _pclass($s->{percentage}, $s->{error});
144 42 ▶ my $ratio = $c eq 'time' ? '' : sprintf('%d of %d', $s->{covered} || 0, $s->{total});
Branch: 1 branch
BranchTrueFalseTotal
$c eq 'time' ? : 49 41 90
Condition50%1/2
$s->{'covered'} || 0
l!l
410
MC/DC0%0/1
$s->{'covered'} || 0
$s->{'covered'}
Truth table50%1/2
A
A= $s->{'covered'}
Aresult
11
00
145 42 printf $fh qq{<div class="tile $class"><span class="name">%s</span><span class="value">%s%%</span><span class="ratio">%s</span></div>\n}, _escape($LABEL{$c}), _pc($s->{percentage}), _escape($ratio);
146 }
147 12 print $fh qq{</section>\n};
148 12 print $fh qq{<p class="tools"><input id="filter" type="search" placeholder="Filter files" aria-label="Filter files"> <span class="hint">Click a column to sort.</span></p>\n};
149 12 print $fh qq{<div class="scroll"><table id="files"><thead><tr><th data-sort="text">file</th>};
150 12 print $fh qq{<th data-sort="num" class="$COLUMN{$_}">$SHORT{$_}</th>} for @$show;
151 12 print $fh qq{<th data-sort="num">total</th></tr></thead>\n<tbody>\n};
152 12 for my $file (@$files) {
153 36 print $fh qq{<tr><td class="f"><a href="$page->{$file}">} . _escape($file) . qq{</a>};
154 36 ▶ if ($xs->{$file}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xs->{$file}) 48 36 84
155 0 print $fh qq{ <a class="xs" href="$page->{$_}" title="the XS of this module: } . _escape($_) . qq{">xs</a>} for @{ $xs->{$file} };
156 }
157 36 print $fh qq{</td>};
158 36 print $fh _summary_cell($db, $file, $_) for @$show;
159 36 print $fh _summary_cell($db, $file, 'total');
160 36 print $fh qq{</tr>\n};
161 }
162 12 print $fh qq{</tbody>\n<tfoot><tr><td class="f">Total</td>};
163 12 print $fh _summary_cell($db, 'Total', $_) for @$show;
164 12 print $fh _summary_cell($db, 'Total', 'total');
165 12 print $fh qq{</tr></tfoot></table></div>\n};
166 12 print $fh qq{</main>\n} . _script() . qq{</body></html>\n};
167 12 close $fh;
168 }
169  
170 76 ▶sub _write_file_page {
Subroutine _write_file_page: called CC=30 SCAR=34.6
171 38 my ($db, $opt, $file, $show, $page, $xs) = @_;
172 38 my $data = $db->cover->file($file);
173 0 ▶ open my $in, '<', $file or do { warn "Can't read file '$file' [$!]\n"; return };
Branch: 1 branch
BranchTrueFalseTotal
open my $in, "<", $file or do { warn "Can't read file '${file}' [$!]\n"; return } 38 96 134
174 38 my @lines = <$in>;
175 38 close $in;
176 38 chomp @lines;
177 38 my $out = File::Spec->catfile($opt->{outputdir}, $page->{$file});
178 38 ▶ open my $fh, '>', $out or do { warn "Can't open file '$out' [$!]\n"; return };
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $out or do { warn "Can't open file '${out}' [$!]\n"; return } 49 2 51
179 37 my $summary = $db->{summary}{$file};
180 37 ▶ my $tot = $summary->{total} || {};
Condition100%2/2
$summary->{'total'} || {}
l!l
361
MC/DC100%1/1
$summary->{'total'} || {}
$summary->{'total'}
Truth table100%2/2
A
A= $summary->{'total'}
Aresult
11
00
181 37 ▶ my $c_file = $file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/u ? : 47 3 50
182 37 my @shown = grep { $data->$_() } @$show;
183 37 print $fh _head($file, 'file');
184 37 ▶ print $fh qq{<header><div><p class="crumb"><a href="} . ($opt->{option}{outputfile} // 'coverage.html') . qq{">summary</a>};
Condition100%2/2
$opt->{"option"}{"outputfile"} // "coverage.html"
l!l
334
MC/DC100%1/1
$opt->{"option"}{"outputfile"} // "coverage.html"
$opt->{"option"}{"outputfile"}
Truth table100%2/2
A
A= $opt->{"option"}{"outputfile"}
Aresult
11
00
185 37 ▶ print $fh qq{ ยท <a href="$page->{$_}">} . _escape($_) . qq{</a>} for @{ $xs->{$file} || [] };
Condition50%1/2
$xs->{$file} || []
l!l
037
MC/DC0%0/1
$xs->{$file} || []
$xs->{$file}
Truth table50%1/2
A
A= $xs->{$file}
Aresult
11
00
186 37 print $fh qq{</p><h1>} . _escape($file) . qq{</h1><p class="meta">};
187 37 my @meta;
188 37 ▶ push @meta, 'total ' . _pc($tot->{percentage}) . '%' if defined $tot->{percentage};
Branch: 1 branch
BranchTrueFalseTotal
if defined $tot->{"percentage"} 36 1 37
189 37 for my $c (@shown) {
190 95 my $s = $summary->{$c};
191 95 ▶ push @meta, $c eq 'time' ? 'time' : sprintf('%s %s%% (%d of %d)', $SHORT{$c}, _pc($s->{percentage}), $s->{covered} || 0, $s->{total});
Branch: 1 branch
BranchTrueFalseTotal
$c eq 'time' ? : 15 93 108
Condition50%1/2
$s->{'covered'} || 0
l!l
930
MC/DC0%0/1
$s->{'covered'} || 0
$s->{'covered'}
Truth table50%1/2
A
A= $s->{'covered'}
Aresult
11
00
192 }
193 37 print $fh _escape(join ' ยท ', @meta) . qq{</p></div>} . _theme_button() . qq{</header>\n<main>\n};
194 37 print $fh qq{<nav class="toggles">};
195 37 print $fh qq{<label><input type="checkbox" data-crit="$COLUMN{$_}" checked> $LABEL{$_}</label> } for @shown;
196 37 print $fh qq{<span class="hint">n and p move between uncovered lines. Click a marked line for what is missing.</span></nav>\n};
197 37 print $fh _legend($c_file, \@shown);
198 37 print $fh qq{<div class="scroll"><table class="src"><thead><tr><th class="n">line</th>};
199 37 print $fh qq{<th class="$COLUMN{$_}">$SHORT{$_}</th>} for @shown;
200 37 print $fh qq{<th class="code">code</th></tr></thead>\n<tbody>\n};
201 37 my ($pod, $ended) = (0, 0);
202 37 my $n = 0;
203 37 for my $text (@lines) {
204 1365 $n++;
205 1365 my $dim = 0;
206 1365 ▶ if ($file =~ /\.p[ml]\z|\.t\z/ || $file !~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /\.p[ml]\z|\.t\z/u or not $file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/u) 9 1369 1378
Condition66%2/3
$file =~ /\.p[ml]\z|\.t\z/u or not $file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/u
l!l&&r!l&&!r
901356
MC/DC50%1/2
$file =~ /\.p[ml]\z|\.t\z/u or not $file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/u
$file =~ /\.p[ml]\z|\.t\z/u not $file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/u
Truth table66%2/3
A or not(B)
A= $file =~ /\.p[ml]\z|\.t\z/uB= not $file =~ /\.(?:xs|c|cc|cpp|cxx|h|hh|hpp)\z/u
ABresult
1X1
011
000
207 9 ▶ $ended = 1 if $text =~ /^__(?:END|DATA)__\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $text =~ /^__(?:END|DATA)__\s*$/u 0 9 9
208 9 ▶ $pod = 1 if !$ended && $text =~ /^=(?:pod|head\d|over|item|begin|for|encoding)\b/;
Branch: 1 branch
BranchTrueFalseTotal
if not $ended and $text =~ /^=(?:pod|head\d|over|item|begin|for|encoding)\b/u 0 9 9
Condition33%1/3
not $ended and $text =~ /^=(?:pod|head\d|over|item|begin|for|encoding)\b/u
!ll&&!rl&&r
090
MC/DC0%0/2
not $ended and $text =~ /^=(?:pod|head\d|over|item|begin|for|encoding)\b/u
not $ended $text =~ /^=(?:pod|head\d|over|item|begin|for|encoding)\b/u
Truth table33%1/3
not(A) and B
A= not $endedB= $text =~ /^=(?:pod|head\d|over|item|begin|for|encoding)\b/u
ABresult
0X0
100
111
209 9 ▶ $dim = $pod || $ended;
Condition33%1/3
$pod || $ended
l!l&&r!l&&!r
009
MC/DC0%0/2
$pod || $ended
$pod $ended
Truth table33%1/3
A || B
A= $podB= $ended
ABresult
1X1
011
000
210 9 ▶ $pod = 0 if $pod && $text =~ /^=cut\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $pod and $text =~ /^=cut\b/u 3 10 13
Condition33%1/3
$pod and $text =~ /^=cut\b/u
!ll&&!rl&&r
900
MC/DC0%0/2
$pod and $text =~ /^=cut\b/u
$pod $text =~ /^=cut\b/u
Truth table33%1/3
A and B
A= $podB= $text =~ /^=cut\b/u
ABresult
0X0
100
111
211 }
212 1365 my (@cells, $miss, @why);
213 1365 for my $c (@shown) {
214 3503 ▶ my $items = $dim ? undef : $data->$c()->location($n);
Branch: 1 branch
BranchTrueFalseTotal
$dim ? : 3 3537 3540
215 3503 my ($cell, $err, @reasons) = _cell($c, $items, $c_file);
216 3503 ▶ $miss ||= $err;
Condition100%3/3
$miss ||= $err
l!l&&r!l&&!r
111923300
MC/DC100%2/2
$miss ||= $err
$miss $err
Truth table100%3/3
A ||= B
A= $missB= $err
ABresult
1X1
011
000
217 3503 push @cells, $cell;
218 3503 push @why, @reasons;
219 }
220 1365 ▶ my $class = join ' ', ($miss ? 'miss' : ()), ($dim ? 'dim' : ());
Branch: 2 branches
BranchTrueFalseTotal
$miss ? : 94 1275 1369
$dim ? : 0 1399 1399
221 1365 ▶ print $fh qq{<tr id="L$n"} . ($class ? qq{ class="$class"} : '') . qq{><td class="n">$n</td>} . join('', @cells) . qq{<td class="code"><pre>} . _escape($text) . qq{</pre></td></tr>\n};
Branch: 1 branch
BranchTrueFalseTotal
$class ? : 187 1655 1842
222 1365 ▶ if (@why) {
Branch: 1 branch
BranchTrueFalseTotal
if (@why) 118 1273 1391
223 92 print $fh qq{<tr class="why"><td class="n"></td><td colspan="} . (@shown + 1) . qq{"><ul>} . join('', map { qq{<li>} . _escape($_) . qq{</li>} } @why) . qq{</ul></td></tr>\n};
224 }
225 }
226 37 print $fh qq{</tbody></table></div>\n</main>\n} . _script() . qq{</body></html>\n};
227 37 close $fh;
228 }
229  
230 7006 ▶sub _cell {
Subroutine _cell: called CC=51 SCAR=41.5
231 3503 my ($criterion, $items, $c_file) = @_;
232 3503 my $col = $COLUMN{$criterion};
233 3503 ▶ return (qq{<td class="$col"></td>}, 0) unless $items;
Branch: 1 branch
BranchTrueFalseTotal
unless $items 3027 479 3506
234 477 my ($html, $err, @why) = ('', 0);
235 477 ▶ if ($criterion eq 'statement' || $criterion eq 'pod') {
Branch: 4 branches
BranchTrueFalseTotal
if ($criterion eq 'statement' or $criterion eq 'pod') { } 308 177 485
elsif ($criterion eq 'time') { } 4 177 181
elsif ($criterion eq 'subroutine') { } 110 67 177
elsif ($criterion eq 'branch') { } 55 12 67
Condition66%2/3
$criterion eq "statement" or $criterion eq "pod"
l!l&&r!l&&!r
3040173
MC/DC50%1/2
$criterion eq "statement" or $criterion eq "pod"
$criterion eq "statement" $criterion eq "pod"
Truth table66%2/3
A or B
A= $criterion eq "statement"B= $criterion eq "pod"
ABresult
1X1
011
000
236 304 for my $i (@$items) {
237 304 my $e = $i->error;
238 304 ▶ $err ||= $e;
Condition66%2/3
$err ||= $e
l!l&&r!l&&!r
046258
MC/DC50%1/2
$err ||= $e
$err $e
Truth table66%2/3
A ||= B
A= $errB= $e
ABresult
1X1
011
000
239 304 my $v = $i->covered;
240 304 ▶ $html .= qq{<span class="} . ($e ? 'c0' : 'c3') . qq{" title="} . _escape("$LABEL{$criterion}: $v") . qq{">$v</span>};
Branch: 1 branch
BranchTrueFalseTotal
$e ? : 46 266 312
241 304 ▶ push @why, $criterion eq 'pod' ? 'no pod for this sub' : 'this line never ran' if $e;
Branch: 2 branches
BranchTrueFalseTotal
if $e 46 262 308
$criterion eq 'pod' ? : 0 46 46
242 }
243 }
244 elsif ($criterion eq 'time') {
245 4 $html .= qq{<span>} . _escape($_->covered) . qq{</span>} for @$items;
246 }
247 elsif ($criterion eq 'subroutine') {
248 110 for my $i (@$items) {
249 117 my $e = $i->error;
250 117 ▶ $err ||= $e;
Condition66%2/3
$err ||= $e
l!l&&r!l&&!r
016101
MC/DC50%1/2
$err ||= $e
$err $e
Truth table66%2/3
A ||= B
A= $errB= $e
ABresult
1X1
011
000
251 117 ▶ $html .= qq{<span class="sub } . ($e ? 'c0' : 'c3') . qq{" title="} . _escape(sprintf '%s: called %d', $i->name, $i->covered) . qq{">} . _escape($i->name) . qq{</span>};
Branch: 1 branch
BranchTrueFalseTotal
$e ? : 16 101 117
252 117 ▶ push @why, sprintf('%s was never called', $i->name) if $e;
Branch: 1 branch
BranchTrueFalseTotal
if $e 16 101 117
253 }
254 }
255 elsif ($criterion eq 'branch') {
256 55 for my $i (@$items) {
257 123 my $e = $i->error;
258 123 ▶ $err ||= $e;
Condition100%3/3
$err ||= $e
l!l&&r!l&&!r
83085
MC/DC100%2/2
$err ||= $e
$err $e
Truth table100%3/3
A ||= B
A= $errB= $e
ABresult
1X1
011
000
259 123 my @v = $i->values;
260 123 ▶ my $text = $i->text // '';
Condition100%2/2
$i->text // ""
l!l
1221
MC/DC100%1/1
$i->text // ""
$i->text
Truth table100%2/2
A
A= $i->text
Aresult
11
00
261 123 ▶ if (my ($k, $n) = $text =~ /^arm (\d+) of (\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $text =~ /^arm (\d+) of (\d+)$/u) 75 48 123
262 75 ▶ my $class = $i->uncoverable(0) ? 'un' : _bclass($v[0]);
Branch: 1 branch
BranchTrueFalseTotal
$i->uncoverable(0) ? : 0 75 75
263 75 ▶ $html .= qq{<span class="branch arm" title="} . _escape(sprintf 'arm %d of %d: taken %d', $k, $n, $v[0] // 0) . qq{"><b class="$class">$k } . ($v[0] // 0) . qq{</b></span>};
Condition50%2/4
$v[0] // 0
l!l
750
$v[0] // 0
l!l
750
MC/DC0%0/1
$v[0] // 0
$v[0]
MC/DC0%0/1
$v[0] // 0
$v[0]
Truth table50%1/2
A
A= $v[0]
Aresult
11
00
Truth table50%1/2
A
A= $v[0]
Aresult
11
00
264 75 ▶ push @why, sprintf('arm %d of the %d-way jump was never taken', $k, $n) if $e && !$i->uncoverable(0);
Branch: 1 branch
BranchTrueFalseTotal
if $e and not $i->uncoverable(0) 17 58 75
Condition66%2/3
$e and not $i->uncoverable(0)
!ll&&!rl&&r
58017
MC/DC50%1/2
$e and not $i->uncoverable(0)
$e not $i->uncoverable(0)
Truth table66%2/3
A and not(B)
A= $eB= not $i->uncoverable(0)
ABresult
0X0
100
111
265 75 next;
266 }
267 48 ▶ my @label = $c_file ? ('A', 'B') : ('T', 'F');
Branch: 1 branch
BranchTrueFalseTotal
$c_file ? : 48 0 48
268 48 ▶ $html .= qq{<span class="branch" title="} . _escape(sprintf '%s: %s %s, %s %s', $text, $c_file ? 'arm A' : 'true', $v[0] // 0, $c_file ? 'arm B' : 'false', $v[1] // 0) . qq{">};
Branch: 2 branches
BranchTrueFalseTotal
$c_file ? : 48 0 48
$c_file ? : 48 0 48
Condition50%2/4
$v[0] // 0
l!l
480
$v[1] // 0
l!l
048
MC/DC0%0/1
$v[0] // 0
$v[0]
MC/DC0%0/1
$v[1] // 0
$v[1]
Truth table50%1/2
A
A= $v[0]
Aresult
11
00
Truth table50%1/2
A
A= $v[1]
Aresult
11
00
269 48 for my $a (0 .. 1) {
270 96 ▶ my $class = $i->uncoverable($a) ? 'un' : _bclass($v[$a]);
Branch: 1 branch
BranchTrueFalseTotal
$i->uncoverable($a) ? : 0 96 96
271 96 ▶ $html .= qq{<b class="$class">$label[$a] } . ($v[$a] // 0) . qq{</b>};
Condition100%2/2
$v[$a] // 0
l!l
4848
MC/DC100%1/1
$v[$a] // 0
$v[$a]
Truth table100%2/2
A
A= $v[$a]
Aresult
11
00
272 }
273 48 $html .= qq{</span>};
274 48 ▶ if ($e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e) 13 35 48
275 13 ▶ my @missing = grep { !$v[$_] && !$i->uncoverable($_) } 0 .. 1;
Condition66%2/3
$v[$_] || $i->uncoverable($_)
l!l&&r!l&&!r
13013
MC/DC50%1/2
$v[$_] || $i->uncoverable($_)
$v[$_] $i->uncoverable($_)
Truth table66%2/3
A || B
A= $v[$_]B= $i->uncoverable($_)
ABresult
1X1
011
000
276 13 my @taken = grep { $v[$_] } 0 .. 1;
277 13 ▶ my $name = length $text ? _short($text) : 'on this line';
Branch: 1 branch
BranchTrueFalseTotal
length $text ? : 12 1 13
278 13 ▶ my $rest = @taken ? sprintf(', %s taken %s', join(' and ', map { "arm $label[$_]" } @taken), join(' and ', map { $v[$_] } @taken))
Branch: 2 branches
BranchTrueFalseTotal
@taken ? : 13 0 13
@missing > 1 ? : 0 0 0
279 : @missing > 1 ? '' : ' and the other never run either';
280 push @why, $c_file
281 13 ▶ ? sprintf('%s of the branch %s %s never taken%s', join(' and ', map { "arm $label[$_]" } @missing), $name, (@missing > 1 ? 'were' : 'was'), $rest)
Branch: 1 branch
BranchTrueFalseTotal
@missing > 1 ? : 0 13 13
282 0 ▶ : sprintf('%s: %s', $name, join(', ', map { $_ ? 'the true branch never taken' : 'the false branch never taken' } map { $_ == 0 ? 1 : 0 } @missing));
Branch: 3 branches
BranchTrueFalseTotal
$c_file ? : 13 0 13
$_ ? : 0 0 0
$_ == 0 ? : 0 0 0
283 }
284 }
285 }
286 else {
287 4 my @tables = eval { Devel::Cover::Report::XSCover::_truth_tables($items) };
288 4 for my $t (@tables) {
289 4 my ($tt, $expr) = @$t;
290 4 ▶ my $e = $tt->percentage < 100 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$tt->percentage < 100 ? : 3 1 4
291 4 $html .= qq{<details class="cond"><summary class="} . _pclass($tt->percentage, $e) . qq{" title="} . _escape($expr) . qq{">} . sprintf('%.0f%%', $tt->percentage) . qq{</summary>} . $tt->html('c0', 'c3') . qq{<p class="expr">} . _escape($expr) . qq{</p></details>};
292 }
293 4 for my $i (@$items) {
294 38 ▶ next unless $i->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $i->error 1 37 38
295 37 $err = 1;
296 37 my $info = $i->[1];
297 37 ▶ if ($info->{op} eq 'of') {
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{'op'} eq 'of') { } 3 34 37
298 3 my @v = @{ $i->[0] };
299 3 my @missing = grep { !$v[$_] } 0 .. 1;
300 3 ▶ push @why, sprintf('%s of the condition %s never decided the result with its %s outcome', $info->{left}, _short($info->{right}), join(' or ', map { $_ ? 'false' : 'true' } @missing));
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 2 2 4
301 }
302 else {
303 34 ▶ push @why, sprintf('the condition %s has combinations never seen%s', join(' ', grep { defined } @{$info}{qw(left op right)}), @tables ? ', open its table' : '');
Branch: 1 branch
BranchTrueFalseTotal
@tables ? : 0 34 34
304 }
305 }
306 }
307 477 ▶ return (qq{<td class="$col">$html</td>}, $err ? 1 : 0, @why);
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 95 382 477
308 }
309  
310 30 ▶sub _short {
Subroutine _short: called CC=2 SCAR=7.0
311 15 my ($text) = @_;
312 15 $text =~ s/^\s+|\s+$//g;
313 15 ▶ $text = substr($text, 0, 57) . '...' if length $text > 60;
Branch: 1 branch
BranchTrueFalseTotal
if length $text > 60 0 15 15
314 15 return $text;
315 }
316  
317 74 ▶sub _legend {
Subroutine _legend: called CC=7 SCAR=19.5
318 37 my ($c_file, $shown) = @_;
319 37 my %has = map { $_ => 1 } @$shown;
320 37 my @items;
321 37 ▶ push @items, 'a green count is a line that ran, a red one a line that never ran' if $has{statement};
Branch: 1 branch
BranchTrueFalseTotal
if $has{"statement"} 33 4 37
322 push @items, $c_file
323 ? 'a branch shows its arms with the times each was taken, A and B, the arm into the body first, or one chip per arm of a switch, red when never'
324 : 'a branch shows T and F with the times each was taken, red when never'
325 37 ▶ if $has{branch};
Branch: 2 branches
BranchTrueFalseTotal
if $has{"branch"} 26 11 37
$c_file ? : 26 0 26
326 push @items, $c_file
327 ? 'a condition (gcc 14 and later) shows, for each term of a decision, whether its true and its false outcome each decided the result, and opens into that table'
328 : 'a condition shows how many of its combinations were seen and opens into its truth table'
329 37 ▶ if $has{condition};
Branch: 2 branches
BranchTrueFalseTotal
if $has{"condition"} 3 34 37
$c_file ? : 1 2 3
330 37 ▶ push @items, 'a subroutine is named on its line, red when never called' if $has{subroutine};
Branch: 1 branch
BranchTrueFalseTotal
if $has{"subroutine"} 31 6 37
331 37 push @items, 'a purple chip is marked uncoverable in the source';
332 37 return qq{<details class="legend"><summary>What the marks mean</summary><ul>} . join('', map { qq{<li>} . _escape($_) . qq{</li>} } @items) . qq{</ul></details>\n};
333 }
334  
335 8 ▶sub _truth_tables {
Subroutine _truth_tables: called CC=5 SCAR=16.1
336 4 my ($items) = @_;
337 4 require Devel::Cover::Truth_Table;
338 4 ▶ return if @$items > 16;
Branch: 1 branch
BranchTrueFalseTotal
if @$items > 16 2 2 4
339 2 my @lops;
340 2 for my $c (@$items) {
341 4 my $op = $c->[1]{type};
342 4 ▶ my @hit = map { $_ > 0 ? 1 : 0 } @{ $c->[0] };
Branch: 1 branch
BranchTrueFalseTotal
$_ > 0 ? : 4 4 8
343 4 ▶ @hit = reverse @hit if $op =~ /^or_[23]$/;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /^or_[23]$/u 0 4 4
344 push @lops, {
345 tt => Devel::Cover::Truth_Table->new_primitive($op, @hit),
346 cvg => $c->[1],
347 4 expr => join(' ', @{ $c->[1] }{qw(left op right)}),
348 };
349 }
350 2 return map { [ $_->{tt}->sort, $_->{expr} ] } _merge_lineops(@lops);
351 }
352  
353 4 ▶sub _merge_lineops {
Subroutine _merge_lineops: called CC=9 SCAR=30.3
354 2 my @ops = @_;
355 2 my $rotations;
356 2 ▶ while ($#ops > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#ops > 0) 4 1 5
357 4 my $rm;
358 4 for (1 .. $#ops) {
359 8 ▶ if ($ops[0]{expr} eq $ops[$_]{cvg}{left}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($ops[0]{'expr'} eq $ops[$_]{'cvg'}{'left'}) { } 0 8 8
elsif ($ops[0]{'expr'} eq $ops[$_]{'cvg'}{'right'}) { } 0 8 8
elsif ($ops[$_]{'expr'} eq $ops[0]{'cvg'}{'left'}) { } 0 8 8
elsif ($ops[$_]{'expr'} eq $ops[0]{'cvg'}{'right'}) { } 0 8 8
360 0 $ops[$_]{tt}->left_merge($ops[0]{tt});
361 0 $ops[0] = $ops[$_];
362 0 $rm = $_;
363 0 last;
364 }
365 elsif ($ops[0]{expr} eq $ops[$_]{cvg}{right}) {
366 0 $ops[$_]{tt}->right_merge($ops[0]{tt});
367 0 $ops[0] = $ops[$_];
368 0 $rm = $_;
369 0 last;
370 }
371 elsif ($ops[$_]{expr} eq $ops[0]{cvg}{left}) {
372 0 $ops[0]{tt}->left_merge($ops[$_]{tt});
373 0 $rm = $_;
374 0 last;
375 }
376 elsif ($ops[$_]{expr} eq $ops[0]{cvg}{right}) {
377 0 $ops[0]{tt}->right_merge($ops[$_]{tt});
378 0 $rm = $_;
379 0 last;
380 }
381 }
382 4 ▶ if ($rm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rm) { } 0 4 4
383 0 splice @ops, $rm, 1;
384 0 $rotations = 0;
385 }
386 else {
387 4 unshift @ops, pop @ops;
388 4 ▶ last if $rotations++ > $#ops;
Branch: 1 branch
BranchTrueFalseTotal
if $rotations++ > $#ops 1 3 4
389 }
390 }
391 2 return @ops;
392 }
393  
394 49 ▶sub _theme_button { qq{<button id="theme" type="button" aria-label="Switch between light and dark">Theme</button>} }
Subroutine _theme_button: called CC=1 SCAR=0.0
395  
396 98 ▶sub _head {
Subroutine _head: called CC=1 SCAR=0.0
397 49 my ($title, $kind) = @_;
398 49 return qq{<!doctype html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>} . _escape($title) . qq{</title>\n<style>\n} . _style() . qq{</style>\n</head>\n<body class="$kind">\n};
399 }
400  
401 98 ▶sub _style {
Subroutine _style: called CC=1 SCAR=0.0
402 49 return <<'CSS';
403 :root{--bg:#f7f7f5;--fg:#1b1b1b;--muted:#6b6b6b;--line:#dcdcd8;--card:#ffffff;--accent:#2d5be3;--c0:#d64545;--c1:#e08a1e;--c2:#c9b325;--c3:#2f9e5b;--c0bg:#fbe4e4;--c1bg:#fdebd3;--c2bg:#f9f3c9;--c3bg:#dff3e6;--unbg:#e9e4f7;--un:#6b4fbb;--here:#2d5be3}
404 @media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--bg:#15171a;--fg:#e6e6e3;--muted:#9a9a96;--line:#2c3036;--card:#1d2024;--accent:#7aa2ff;--c0:#ff7b7b;--c1:#ffb45c;--c2:#e8d35a;--c3:#5fd38d;--c0bg:#3a1f22;--c1bg:#3a2c1a;--c2bg:#36331c;--c3bg:#1c3326;--unbg:#2a2440;--un:#b9a6ff;--here:#7aa2ff}}
405 :root[data-theme="dark"]{--bg:#15171a;--fg:#e6e6e3;--muted:#9a9a96;--line:#2c3036;--card:#1d2024;--accent:#7aa2ff;--c0:#ff7b7b;--c1:#ffb45c;--c2:#e8d35a;--c3:#5fd38d;--c0bg:#3a1f22;--c1bg:#3a2c1a;--c2bg:#36331c;--c3bg:#1c3326;--unbg:#2a2440;--un:#b9a6ff;--here:#7aa2ff}
406 *{box-sizing:border-box}
407 body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
408 header{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:20px 16px 8px;max-width:1200px;margin:0 auto}
409 main{padding:0 16px 40px;max-width:1200px;margin:0 auto}
410 h1{font-size:1.5rem;margin:0 0 4px;word-break:break-all}
411 .meta,.crumb,.hint{color:var(--muted);font-size:.9rem;margin:0}
412 .crumb a,a{color:var(--accent)}
413 button#theme{background:var(--card);color:var(--fg);border:1px solid var(--line);border-radius:6px;padding:6px 10px;font:inherit;cursor:pointer}
414 .tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px;margin:12px 0 16px}
415 .tile{background:var(--card);border:1px solid var(--line);border-left:4px solid var(--c3);border-radius:8px;padding:10px 12px;display:flex;flex-direction:column}
416 .tile.c0{border-left-color:var(--c0)}.tile.c1{border-left-color:var(--c1)}.tile.c2{border-left-color:var(--c2)}
417 .tile .name{color:var(--muted);font-size:.85rem}.tile .value{font-size:1.4rem;font-weight:600}.tile .ratio{color:var(--muted);font-size:.8rem}
418 .tools{display:flex;gap:12px;align-items:center;margin:0 0 8px}
419 input#filter{font:inherit;padding:6px 10px;border:1px solid var(--line);border-radius:6px;background:var(--card);color:var(--fg);min-width:200px}
420 .scroll{overflow-x:auto;background:var(--card);border:1px solid var(--line);border-radius:8px}
421 table{border-collapse:collapse;width:100%}
422 th,td{padding:4px 8px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top;white-space:nowrap}
423 thead th{position:sticky;top:0;background:var(--card);font-weight:600;color:var(--muted);font-size:.85rem;z-index:1}
424 #files thead th{cursor:pointer;user-select:none}
425 #files thead th[data-sort="num"]{text-align:right}
426 #files td.pc,#files th[data-sort="num"]{width:9.5em}
427 #files td.pc span{display:inline-block;min-width:3.6em;text-align:right}
428 #files thead th[data-dir="asc"]::after{content:" \25B2"}#files thead th[data-dir="desc"]::after{content:" \25BC"}
429 #files td.f{white-space:normal;word-break:break-all}
430 #files tfoot td{font-weight:600}
431 td.pc{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
432 td.pc meter{width:60px;height:10px;margin-right:6px;vertical-align:middle}
433 td.pc.c0 meter::-webkit-meter-optimum-value{background:var(--c0)}td.pc.c1 meter::-webkit-meter-optimum-value{background:var(--c1)}td.pc.c2 meter::-webkit-meter-optimum-value{background:var(--c2)}td.pc.c3 meter::-webkit-meter-optimum-value{background:var(--c3)}
434 td.pc.c0 meter::-moz-meter-bar{background:var(--c0)}td.pc.c1 meter::-moz-meter-bar{background:var(--c1)}td.pc.c2 meter::-moz-meter-bar{background:var(--c2)}td.pc.c3 meter::-moz-meter-bar{background:var(--c3)}
435 td.pc.c0 span{color:var(--c0)}td.pc.c1 span{color:var(--c1)}td.pc.c2 span{color:var(--c2)}td.pc.c3 span{color:var(--c3)}
436 td.na{color:var(--muted)}
437 a.xs{font-size:.75rem;border:1px solid var(--accent);border-radius:4px;padding:0 4px;text-decoration:none;margin-left:6px}
438 .toggles{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin:10px 0}
439 .toggles label{cursor:pointer}
440 table.src{font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
441 table.src td{padding:0 8px;border-bottom:0}
442 table.src td.br,table.src td.sb,table.src td.cd{white-space:normal;max-width:18em;line-height:1.3}
443 table.src tr.why{display:none}table.src tr.why.open{display:table-row}
444 table.src tr.why td{background:var(--c0bg);font:14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;white-space:normal;padding:4px 12px}
445 table.src tr.why ul{margin:0;padding-left:18px}
446 table.src tr.miss td.n{cursor:pointer}
447 details.legend{margin:0 0 10px;color:var(--muted);font-size:.9rem}details.legend summary{cursor:pointer}details.legend ul{margin:4px 0 0;padding-left:18px}
448 table.src td.n{color:var(--muted);text-align:right;user-select:none;width:1%}
449 table.src td.code{width:100%;white-space:pre}
450 table.src td.code pre{margin:0;font:inherit;white-space:pre}
451 table.src tr.miss td.code{background:var(--c0bg)}
452 table.src tr.miss td.n{color:var(--c0);font-weight:600}
453 table.src tr.here td{outline:2px solid var(--here);outline-offset:-2px}
454 table.src tr.dim td.code{color:var(--muted)}
455 table.src td.st span,table.src td.pd span{display:inline-block;min-width:1.5em;text-align:right;padding:0 4px;border-radius:4px;font-size:.85em}
456 table.src td.st span.c3,table.src td.pd span.c3{background:var(--c3bg);color:var(--c3)}
457 table.src td.st span.c0,table.src td.pd span.c0{background:var(--c0bg);color:var(--c0)}
458 table.src td.tm span{color:var(--muted);font-size:.85em}
459 span.branch{display:inline-flex;margin-right:4px;border-radius:4px;overflow:hidden;border:1px solid var(--line);font-size:.75em;vertical-align:middle}
460 span.branch b{padding:0 5px;font-weight:600;white-space:nowrap}
461 span.branch{margin:1px 4px 1px 0}
462 span.branch b.c3{background:var(--c3bg);color:var(--c3)}span.branch b.c0{background:var(--c0bg);color:var(--c0)}span.branch b.un{background:var(--unbg);color:var(--un)}
463 span.sub{display:inline-block;padding:0 6px;border-radius:4px;font-size:.85em;margin-right:4px}
464 span.sub.c3{background:var(--c3bg);color:var(--c3)}span.sub.c0{background:var(--c0bg);color:var(--c0)}
465 details.cond{display:inline-block;margin-right:4px;font-size:.85em}
466 details.cond summary{cursor:pointer;padding:0 6px;border-radius:4px;list-style:none}
467 details.cond summary.c0{background:var(--c0bg);color:var(--c0)}details.cond summary.c1{background:var(--c1bg);color:var(--c1)}details.cond summary.c2{background:var(--c2bg);color:var(--c2)}details.cond summary.c3{background:var(--c3bg);color:var(--c3)}
468 details.cond[open]{position:relative}
469 details.cond table{position:absolute;z-index:2;background:var(--card);border:1px solid var(--line);border-radius:6px;padding:4px;width:auto;box-shadow:0 4px 16px rgba(0,0,0,.15)}
470 details.cond td,details.cond th{padding:1px 6px;border:0;text-align:center}
471 details.cond .c0{color:var(--c0)}details.cond .c3{color:var(--c3)}
472 details.cond p.expr{margin:0;color:var(--muted);display:none}
473 .hide-st .st,.hide-br .br,.hide-cd .cd,.hide-sb .sb,.hide-pd .pd,.hide-tm .tm{display:none}
474 @media (max-width:600px){header{flex-direction:column}td.pc meter{display:none}}
475 CSS
476 }
477  
478 98 ▶sub _script {
Subroutine _script: called CC=1 SCAR=0.0
479 49 return <<'JS';
480 <script>
481 (function(){
482 var root=document.documentElement;
483 try{var saved=localStorage.getItem('xs-cover-theme');if(saved)root.setAttribute('data-theme',saved)}catch(e){}
484 var theme=document.getElementById('theme');
485 if(theme)theme.onclick=function(){var cur=root.getAttribute('data-theme');var dark=cur?cur==='dark':window.matchMedia('(prefers-color-scheme: dark)').matches;var next=dark?'light':'dark';root.setAttribute('data-theme',next);try{localStorage.setItem('xs-cover-theme',next)}catch(e){}};
486 var files=document.getElementById('files');
487 if(files){
488 var ths=files.querySelectorAll('thead th');
489 Array.prototype.forEach.call(ths,function(th,i){th.onclick=function(){var num=th.getAttribute('data-sort')==='num';var body=files.tBodies[0];var rows=Array.prototype.slice.call(body.rows);var asc=th.getAttribute('data-dir')!=='asc';Array.prototype.forEach.call(ths,function(h){h.removeAttribute('data-dir')});th.setAttribute('data-dir',asc?'asc':'desc');
490 function key(r){var c=r.cells[i];var v=c.getAttribute('data-v');if(v===null)v=c.textContent.trim();return num?parseFloat(v):v.toLowerCase()}
491 rows.sort(function(a,b){var x=key(a),y=key(b);if(num){if(isNaN(x))x=-1;if(isNaN(y))y=-1;return asc?x-y:y-x}return asc?x.localeCompare(y):y.localeCompare(x)});
492 rows.forEach(function(r){body.appendChild(r)})}});
493 var filter=document.getElementById('filter');
494 if(filter)filter.oninput=function(){var q=filter.value.toLowerCase();Array.prototype.forEach.call(files.tBodies[0].rows,function(r){r.hidden=q!==''&&r.cells[0].textContent.toLowerCase().indexOf(q)<0})};
495 }
496 Array.prototype.forEach.call(document.querySelectorAll('input[data-crit]'),function(c){c.onchange=function(){root.classList.toggle('hide-'+c.getAttribute('data-crit'),!c.checked)}});
497 var miss=Array.prototype.slice.call(document.querySelectorAll('tr.miss')),at=-1;
498 Array.prototype.forEach.call(document.querySelectorAll('tr.miss'),function(r){r.onclick=function(e){if(e.target.closest('details'))return;var w=r.nextElementSibling;if(w&&w.classList.contains('why'))w.classList.toggle('open')}});
499 document.addEventListener('keydown',function(e){if(e.target&&(e.target.tagName==='INPUT'||e.target.tagName==='TEXTAREA'))return;if(e.key!=='n'&&e.key!=='p')return;if(!miss.length)return;at=e.key==='n'?(at+1)%miss.length:(at-1+miss.length)%miss.length;miss.forEach(function(r){r.classList.remove('here')});miss[at].classList.add('here');var w=miss[at].nextElementSibling;if(w&&w.classList.contains('why'))w.classList.add('open');miss[at].scrollIntoView({block:'center'})});
500 })();
501 </script>
502 JS
503 }
504  
505 16 1;
506  
507 __END__
↑ Summary blib/lib/Devel/XSCover/DB.pm »