blib/lib/Perl6/Form.pm

filter: Statementstmt 49.3% 482 / 977 Branchbran 30.3% 173 / 570 Conditioncond 28.6% 104 / 363 MC/DCmcdc 8.0% 16 / 200 Subroutinesub 51.9% 53 / 102 Podpod 0.0% 0 / 57 totaltotal 36.4% 828 / 2269 CC 487 SCAR 68.5
CC
487
Cov
40%
make_cols
4606.2
segment
1129.5
__ANON__
452.9
CRAP 939.9
↑ Summary
1 package Perl6::Form;
2 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 our $VERSION = '0.090';
5  
6 2 ▶use Perl6::Export;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 0 ▶use Scalar::Util qw( readonly );
Subroutine BEGIN: called CC=1 SCAR=1.5
Subroutine BEGIN: called CC=2 SCAR=9.7
Subroutine BEGIN: called CC=1 SCAR=1.5
Subroutine import: called CC=8 SCAR=29.1
Branch: 3 branches
BranchTrueFalseTotal
if ($i < @_) 0 2 2
if (not ref $_ and /^[:\$&%\@]?(\w+)$/ and exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}) 0 0 0
unless @exports 2 0 2
Condition9%1/11
$EXPORT_TAGS{"MANDATORY"} ||= []
l!l
02
not ref $_ and /^[:\$&%\@]?(\w+)$/ and exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}
!ll&&!rl&&r
000
not ref $_ and /^[:\$&%\@]?(\w+)$/
!ll&&!rl&&r
000
exists $EXPORT{$1} or exists $EXPORT_TAGS{$1}
l!l&&r!l&&!r
000
MC/DC0%0/1
$EXPORT_TAGS{"MANDATORY"} ||= []
$EXPORT_TAGS{"MANDATORY"}
MC/DC0%0/4
not ref $_ and /^[:\$&%\@]?(\w+)$/ and exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}
not ref $_ /^[:\$&%\@]?(\w+)$/ exists $EXPORT{$1} exists $EXPORT_TAGS{$1}
Truth table50%1/2
A
A= $EXPORT_TAGS{"MANDATORY"}
Aresult
11
00
Truth table0%0/5
not(A) and B and C or D
A= not ref $_B= /^[:\$&%\@]?(\w+)$/C= exists $EXPORT{$1}D= exists $EXPORT_TAGS{$1}
ABCDresult
0XXX0
10XX0
11000
111X1
11011
8 2 ▶use List::Util qw( max min first );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use charnames ':full';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 my %caller_opts;
13  
14 0 ▶sub fatal {
Subroutine fatal: not called CC=1 SCAR=6.9
Pod undocumented
15 0 croak @_, "\nin call to &form";
16 }
17  
18 0 ▶sub defined_or_space {
Subroutine defined_or_space: not called CC=3 SCAR=24.8
Pod undocumented
19 0 ▶ return " " if !defined $_[0] || length $_[0] == 0;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_[0] or length $_[0] == 0 0 0 0
Condition0%0/3
not defined $_[0] or length $_[0] == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $_[0] or length $_[0] == 0
not defined $_[0] length $_[0] == 0
Truth table0%0/3
not(A) or B
A= not defined $_[0]B= length $_[0] == 0
ABresult
1X1
011
000
20 0 return $_[0];
21 }
22  
23 0 ▶sub boolean {
Subroutine boolean: not called CC=2 SCAR=17.9
Pod undocumented
24 0 ▶ return $_[0] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 0 0
25 }
26  
27 0 ▶sub pattern {
Subroutine pattern: not called CC=3 SCAR=24.8
Pod undocumented
28 0 ▶ return $_[0] if ref $_[0] eq 'Regexp';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "Regexp" 0 0 0
29 0 ▶ return $_[0] ? qr/(?=)/ : qr/(?!)/;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 0 0
30 }
31  
32 0 ▶sub code {
Subroutine code: not called CC=3 SCAR=24.8
Pod undocumented
33 0 my ($newval, $name ) = @_;
34 0 ▶ my $type = ref($newval) || "'$newval'";
Condition0%0/2
ref $newval || "'${newval}'"
l!l
00
MC/DC0%0/1
ref $newval || "'${newval}'"
ref $newval
Truth table0%0/2
A
A= ref $newval
Aresult
11
00
35 0 ▶ fatal "Value for '$name' option must be code reference (not $type)"
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "CODE" 0 0 0
36 unless $type eq 'CODE';
37 0 return $newval;
38 }
39  
40 2 my %std_one = (
41 '=' => '{=[{1}[=}',
42 '_' => '{_[{1}[_}',
43 );
44  
45 0 ▶sub one_char {
Subroutine one_char: not called CC=5 SCAR=34.0
Pod undocumented
46 0 my ($newval, undef, $opts ) = @_;
47 0 ▶ $newval = [ $newval ] unless ref $newval eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $newval eq "ARRAY" 0 0 0
48 0 for (@$newval) {
49 0 ▶ fatal "Value for 'single' option must be single character (not '$_')"
Branch: 1 branch
BranchTrueFalseTotal
if length $_ != 1 0 0 0
50 if length() != 1;
51 $opts->{field} =
52 0 ▶ user_def([qr/\Q$_\E/, $std_one{$_}||'{[{1}[}'], 'single', $opts);
Condition0%0/2
$std_one{$_} || '{[{1}[}'
l!l
00
MC/DC0%0/1
$std_one{$_} || '{[{1}[}'
$std_one{$_}
Truth table0%0/2
A
A= $std_one{$_}
Aresult
11
00
53 }
54 0 return;
55 }
56  
57 0 ▶sub layout_word {
Subroutine layout_word: not called CC=2 SCAR=17.9
Pod undocumented
58 0 ▶ fatal "Value for layout option must be 'across', 'down', 'balanced', ",
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ /^(across|down|balanced|tabular)$/ 0 0 0
59 "or 'tabular\n(not '$_[0]')"
60 unless $_[0] =~ /^(across|down|balanced|tabular)$/;
61 0 return $_[0];
62 }
63  
64 0 ▶sub pos_integer {
Subroutine pos_integer: not called CC=3 SCAR=24.8
Pod undocumented
65 0 ▶ fatal "Value for '$_[1]' option must be positive integer (not $_[0])"
Branch: 1 branch
BranchTrueFalseTotal
unless int $_[0] eq $_[0] and $_[0] > 0 0 0 0
Condition0%0/3
int $_[0] eq $_[0] and $_[0] > 0
!ll&&!rl&&r
000
MC/DC0%0/2
int $_[0] eq $_[0] and $_[0] > 0
int $_[0] eq $_[0] $_[0] > 0
Truth table0%0/3
A and B
A= int $_[0] eq $_[0]B= $_[0] > 0
ABresult
0X0
100
111
66 unless int($_[0]) eq $_[0] && $_[0] > 0;
67 0 return $_[0];
68 }
69  
70 0 ▶sub strings_or_undef {
Subroutine strings_or_undef: not called CC=4 SCAR=30.0
Pod undocumented
71 0 my ($val, $name) = @_;
72 0 my $type = ref $val;
73 0 ▶ if (!defined $val) { $val = [] }
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $val) { } 0 0 0
elsif (not $type) { } 0 0 0
74 0 elsif (!$type) { $val = [ "$val" ] }
75 0 ▶ fatal "Value for '$name' option must be string, array of strings, or undef (not \L$type\E)"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $val eq "ARRAY" 0 0 0
76 unless ref $val eq 'ARRAY';
77 0 return $val;
78 }
79  
80 2 my $unlimited = ~0>>1; # Ersatz infinity
81  
82 0 ▶sub height_vals {
Subroutine height_vals: not called CC=10 SCAR=47.0
Pod undocumented
83 0 my ($vals) = @_;
84 0 my $type = ref $vals;
85 0 ▶ if (!defined $vals) { $vals = {min=>0, max=>$unlimited} }
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $vals) { } 0 0 0
elsif (not $type and $vals eq 'minimal') { } 0 0 0
elsif (not $type) { } 0 0 0
elsif ($type eq 'HASH') { } 0 0 0
86 ▶ elsif (!$type && $vals eq 'minimal')
Condition0%0/3
not $type and $vals eq "minimal"
!ll&&!rl&&r
000
MC/DC0%0/2
not $type and $vals eq "minimal"
not $type $vals eq "minimal"
Truth table0%0/3
not(A) and B
A= not $typeB= $vals eq "minimal"
ABresult
0X0
100
111
87 0 { $vals = {min=>0, max=>$unlimited, minimal=>1} }
88 0 elsif (!$type) { $vals = {min=>$vals, max=>$vals} }
89 0 ▶ elsif ($type eq 'HASH') { $vals->{min}||=0;
Condition0%0/2
$vals->{"min"} ||= 0
l!l
00
MC/DC0%0/1
$vals->{"min"} ||= 0
$vals->{"min"}
Truth table0%0/2
A
A= $vals->{"min"}
Aresult
11
00
90 0 ▶ defined $vals->{max} or $vals->{max}=$unlimited;
Branch: 1 branch
BranchTrueFalseTotal
defined $vals->{"max"} or $vals->{"max"} = $unlimited 0 0 0
91 }
92 fatal "Values for height option must be positive integers (not $_[0])"
93 unless ref $vals eq 'HASH'
94 0 ▶ && !grep {int($vals->{$_}) ne $vals->{$_}} qw(min max);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $vals eq "HASH" and not grep({int $vals->{$_} ne $vals->{$_};} "min", "max") 0 0 0
Condition0%0/3
ref $vals eq "HASH" and not grep({int $vals->{$_} ne $vals->{$_};} "min", "max")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $vals eq "HASH" and not grep({int $vals->{$_} ne $vals->{$_};} "min", "max")
ref $vals eq "HASH" not grep({int $vals->{$_} ne $vals->{$_};} "min", "max")
Truth table0%0/3
A and not(B)
A= ref $vals eq "HASH"B= not grep({int $vals->{$_} ne $vals->{$_};} "min", "max")
ABresult
0X0
100
111
95 0 return $vals;
96 }
97  
98 66 ▶my %nothing = map {$_=>sub{""}} qw(first even odd other);
Subroutine __ANON__: called CC=1 SCAR=0.0
99  
100 22 ▶sub std_body {
Subroutine std_body: called CC=1 SCAR=0.0
Pod undocumented
101 22 my ($rows, $fill, $opt) = @_;
102 22 join("", @$rows, @$fill);
103 }
104 2 my %std_body = (other =>\&std_body);
105  
106 2 my %def_page = (
107 length => $unlimited,
108 width => 78,
109 header => \%nothing, # Args: ($opts)
110 footer => \%nothing, # Args: ($opts)
111 body => \%std_body, # Args: ($body_rows, $body_len, $opts)
112 feed => \%nothing, # Args: ($opts)
113 number => undef,
114 );
115  
116 0 ▶sub form_body {
Subroutine form_body: not called CC=2 SCAR=17.9
Pod undocumented
117 0 my ($format) = @_;
118 0 ▶ $format = '{[{*}[}' unless defined $format;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $format 0 0 0
119 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
120 0 my ($rows, $fill, $opt) = @_;
121 0 my %form_opts = ( page=>{width => $opt->{page}{width}} );
122 0 @{$form_opts{height}}{qw(min max)} = (@$rows+@$fill) x 2
123 0 ▶ unless $opt->{page}{length} == $unlimited;
Branch: 1 branch
BranchTrueFalseTotal
unless $opt->{"page"}{"length"} == $unlimited 0 0 0
124 0 return form(\%form_opts, $format, $rows);
125 }
126 0 }
127  
128 0 ▶sub hashify {
Subroutine hashify: not called CC=9 SCAR=45.0
Pod undocumented
129 0 my ($what, $val, $default_undef, $default_val) = @_;
130 0 ▶ if (!defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val) 0 0 0
131 0 return { other => $default_undef};
132 }
133 0 ▶ if (!ref $val) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $val) 0 0 0
134 0 return { other => $default_val->($val) };
135 }
136 0 ▶ if (ref $val eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq "CODE") 0 0 0
137 0 return { other => $val };
138 }
139 0 ▶ if (ref $val eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq "HASH") 0 0 0
140 fatal "Invalid key for $what: '$_'"
141 0 for grep { !/^(first|last|even|odd|other)$/ } keys %$val;
142 0 my %hash;
143 0 for (keys %$val) {
144 0 ▶ if (!ref $val->{$_}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $val->{$_}) { } 0 0 0
elsif (ref $val->{$_} ne 'CODE') { } 0 0 0
145 0 $hash{$_} = $default_val->($val->{$_})
146 }
147 elsif (ref $val->{$_} ne 'CODE') {
148 0 fatal "Value for $what '$_' must be string or subroutine";
149 }
150 else {
151 0 $hash{$_} = $val->{$_};
152 }
153 }
154 0 return \%hash;
155 }
156 0 fatal "Value for $what must be string, subroutine, or hash";
157 }
158  
159 0 ▶sub page_hash {
Subroutine page_hash: not called CC=5 SCAR=34.0
Pod undocumented
160 0 my ($h, undef, $opts) = @_;
161 fatal "Value for 'page' option must be hash reference (not $_)"
162 0 for grep $_ ne 'HASH', ref $h;
163 0 $h = { %{$opts->{page}}, %$h };
164 fatal "Unknown page sub-option ('$_')"
165 0 for grep {!exists $def_page{$_}} keys %$h;
166 fatal "Page $_ must be greater than zero"
167 0 for grep $h->{$_} <= 0, qw(length width);
168 $h->{body} =
169 0 hashify("body preprocessor", $h->{body}, \&std_body, \&form_body);
170 0 for (qw( header footer feed )) {
171 0 ▶ $h->{$_} = hashify($_, $h->{$_}, sub{""}, sub{my($str)=@_; sub{$str}});
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
172 }
173 0 return $h;
174 }
175  
176 0 ▶sub filehandle {
Subroutine filehandle: not called CC=2 SCAR=17.9
Pod undocumented
177 fatal "Value for 'out' option must be filehandle (not '$_')"
178 0 for grep {$_ ne 'GLOB' } ref $_[0];
179 0 return $_[0];
180 }
181  
182 0 ▶sub user_def {
Subroutine user_def: not called CC=9 SCAR=45.0
Pod undocumented
183 0 my ($spec, $name, $opts) = @_;
184 0 my $type = ref $spec;
185 0 ▶ fatal "Value of 'field' option must be an array of pairs or a hash (not ",
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^(ARRAY|HASH)$/ 0 0 0
Condition0%0/2
$type || "'${spec}'"
l!l
00
MC/DC0%0/1
$type || "'${spec}'"
$type
Truth table0%0/2
A
A= $type
Aresult
11
00
186 $type||"'$spec'", ")"
187 unless $type =~ /^(ARRAY|HASH)$/;
188 0 ▶ if ($type eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'ARRAY') { } 0 0 0
189 0 ▶ fatal "Missing value for last user-defined field ('$spec->[-1]')"
Branch: 1 branch
BranchTrueFalseTotal
if @$spec % 2 0 0 0
190 if @$spec % 2;
191 }
192 else {
193 0 $spec = [%$spec];
194 }
195 0 ▶ my @from = @{$opts->{field}{from}||=[]};
Condition0%0/2
$opts->{"field"}{"from"} ||= []
l!l
00
MC/DC0%0/1
$opts->{"field"}{"from"} ||= []
$opts->{"field"}{"from"}
Truth table0%0/2
A
A= $opts->{"field"}{"from"}
Aresult
11
00
196 0 ▶ my @to = @{$opts->{field}{to}||=[]};
Condition0%0/2
$opts->{"field"}{"to"} ||= []
l!l
00
MC/DC0%0/1
$opts->{"field"}{"to"} ||= []
$opts->{"field"}{"to"}
Truth table0%0/2
A
A= $opts->{"field"}{"to"}
Aresult
11
00
197 0 my $count = @from;
198 0 ▶ for (my $i=0; $i<@$spec; $i+=2, $count++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$spec) 0 0 0
199 0 my ($pat, $fld) = @{$spec}[$i,$i+1];
200 0 push @from, "$pat(?{$count})";
201 0 ▶ push @to, (ref $fld eq 'CODE' ? $fld : sub{$fld});
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $fld eq 'CODE' ? : 0 0 0
202 }
203 0 return {from=>\@from, to=>\@to};
204 }
205  
206 my %std_opt = (
207 out => { set => \&filehandle, def => \*STDOUT, },
208 ws => { set => \&pattern, def => undef, },
209 fill => { set => \&defined_or_space, def => " ", },
210 lfill => { set => \&defined_or_space, def => undef, },
211 rfill => { set => \&defined_or_space, def => undef, },
212 hfill => { set => \&defined_or_space, def => undef, },
213 tfill => { set => \&defined_or_space, def => undef, },
214 bfill => { set => \&defined_or_space, def => undef, },
215 vfill => { set => \&defined_or_space, def => undef, },
216 single => { set => \&one_char, def => undef, },
217 field => { set => \&user_def, def => {from=>[],to=>[]} },
218 bullet => { set => \&strings_or_undef, def => [] },
219 height => { set => \&height_vals, def => {min=>0, max=>$unlimited} },
220 layout => { set => \&layout_word, def => 'balanced', },
221 break => { set => \&code, def => break_at('-'), },
222 page => { set => \&page_hash, def => {%def_page}, },
223 0 ▶ under => { set => sub {"$_[0]"}, def => undef },
Subroutine __ANON__: not called CC=1 SCAR=1.2
224 interleave => { set => \&boolean, def => 0 },
225 untrimmed => { set => \&boolean, def => 0, },
226 locale => { set => \&boolean, def => 0, },
227 );
228  
229 2 my %def_opts = map {$_=>$std_opt{$_}{def}} keys %std_opt;
230  
231 0 ▶sub get_locale_vals { # args: $dec_mark, $thou_sep, $thou_group
Subroutine get_locale_vals: not called CC=4 SCAR=24.2
Pod undocumented
232 2 ▶ use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
233 0 $lconv = POSIX::localeconv();
234 0 ▶ $_[0] = exists $lconv->{decimal_point} ? $lconv->{decimal_point} : "?";
Branch: 1 branch
BranchTrueFalseTotal
exists $lconv->{'decimal_point'} ? : 0 0 0
235 0 ▶ $_[1] = exists $lconv->{thousands_sep} ? $lconv->{thousands_sep} : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $lconv->{'thousands_sep'} ? : 0 0 0
236 0 ▶ $_[2] = exists $lconv->{grouping} ? [unpack "c*", $lconv->{grouping}] : [0];
Branch: 1 branch
BranchTrueFalseTotal
exists $lconv->{'grouping'} ? : 0 0 0
237 }
238  
239 2 my %std_literal = (
240 break => \&break_lit,
241 literal => 1,
242 vjust => \&jverlit,
243 hjust => \&jhorlit,
244 );
245  
246 0 ▶sub update(\%\%;$) {
Subroutine update: not called CC=7 SCAR=40.3
Pod undocumented
247 0 my ($old, $new, $croak) = @_;
248 0 my @bad;
249 0 for my $opt (keys %$new) {
250 0 my $std = $std_opt{$opt};
251 0 ▶ push @bad, "Unknown option: $opt=>'$new->{$opt}" and next unless $std;
Branch: 1 branch
BranchTrueFalseTotal
unless $std 0 0 0
Condition0%0/5
$std || push(@bad, "Unknown option: $opt=>'$new->{$opt}") && (next)
l!l&&r!l&&!r
000
push @bad, "Unknown option: $opt=>'$new->{$opt}" and next
!ll
00
MC/DC0%0/2
$std || push(@bad, "Unknown option: $opt=>'$new->{$opt}") && (next)
$std push @bad, "Unknown option: $opt=>'$new->{$opt}"
Truth table0%0/3
A || B
A= $stdB= push @bad, "Unknown option: $opt=>'$new->{$opt}"
ABresult
1X1
011
000
252 0 $old->{$opt} = $std->{set}->($new->{$opt}, $opt, $old);
253 }
254 0 ▶ if (@bad && $croak) { croak join "\n", @bad }
Branch: 2 branches
BranchTrueFalseTotal
if (@bad and $croak) { } 0 0 0
elsif (@bad) { } 0 0 0
Condition0%0/3
@bad and $croak
!ll&&!rl&&r
000
MC/DC0%0/2
@bad and $croak
@bad $croak
Truth table0%0/3
A and B
A= @badB= $croak
ABresult
0X0
100
111
255 0 elsif (@bad) { fatal join "\n", @bad }
256 }
257  
258  
259  
260 # Horizontal justifiers
261  
262 8 ▶sub fillpat {
Subroutine fillpat: called CC=2 SCAR=7.1
Pod undocumented
263 8 my ($pos, $fill, $len) = @_;
264 8 ▶ return "" if $len < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $len < 0 0 8 8
265 8 return substr($fill x max(0,($pos+$len)/length($fill)+1), $pos, $len);
266 }
267  
268 44 ▶sub jhorlit {} # literals don't need any justification
Subroutine jhorlit: called CC=1 SCAR=0.0
Pod undocumented
269  
270 0 ▶sub jverbatim {
Subroutine jverbatim: not called CC=1 SCAR=6.9
Pod undocumented
271 0 jleft(@_, precropped=>1);
272 }
273  
274 4 ▶sub jleft {
Subroutine jleft: called CC=3 SCAR=11.3
Pod undocumented
275 4 my (undef, %val) = @_;
276 4 ▶ $_[0] =~ s/^\s+// unless $val{precropped};
Branch: 1 branch
BranchTrueFalseTotal
unless $val{"precropped"} 0 4 4
277 4 my $len = length $_[0];
278 4 $_[0] .= fillpat($val{pos}+$len, $val{post}, $val{width}-$len);
279 4 ▶ substr($_[0],$val{width}) = "" unless $val{stretch};
Branch: 1 branch
BranchTrueFalseTotal
unless $val{"stretch"} 4 0 4
280 }
281  
282 4 ▶ sub jright {
Subroutine jright: called CC=3 SCAR=11.4
Pod undocumented
283 4 my (undef, %val) = @_;
284 4 ▶ $_[0] =~ s/\s+$// unless $val{precropped};
Branch: 1 branch
BranchTrueFalseTotal
unless $val{"precropped"} 0 4 4
285 4 $_[0] = fillpat($val{pos}, $val{pre}, $val{width}-length($_[0])) . $_[0];
286 4 ▶ substr($_[0],0,-$val{width}) = "" unless $val{stretch};
Branch: 1 branch
BranchTrueFalseTotal
unless $val{"stretch"} 4 0 4
287 }
288  
289 0 ▶ sub jcentre {
Subroutine jcentre: not called CC=1 SCAR=6.9
Pod undocumented
290 0 my (undef, %val) = @_;
291 0 $_[0] =~ s/^\s+|\s+$//g;
292 0 $val{precropped} = 1;
293 0 my $indent = int( ($val{width}-length $_[0])/2 );
294 0 jleft($_[0], %val, stretch=>0, pos=>$val{pos}+$indent, width=>$val{width}-$indent);
295 0 jright($_[0], %val);
296 }
297  
298 0 ▶ sub jfull {
Subroutine jfull: not called CC=5 SCAR=34.0
Pod undocumented
299 0 my ($str, %val) = @_;
300 0 my $rem = $val{width};
301 0 $str =~ s/^\s+|\s+$//g;
302 0 ▶ unless ($val{last}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($val{"last"}) 0 0 0
303 0 my $rem = $val{width}-length($str);
304 0 $str = reverse $str;
305 0 ▶ 1 while $rem>0 && $str =~ s/( +)/($rem-->0?" ":"").$1/ge;
Branch: 2 branches
BranchTrueFalseTotal
$rem > 0 and $str =~ s/( +)/($rem-- > 0 ? " " : "") . $1;/eg and do { '???' } 0 0 0
$rem-- > 0 ? : 0 0 0
Condition0%0/3
$rem > 0 and $str =~ s/( +)/($rem-- > 0 ? " " : "") . $1;/eg
!ll&&!rl&&r
000
MC/DC0%0/2
$rem > 0 and $str =~ s/( +)/($rem-- > 0 ? " " : "") . $1;/eg
$rem > 0 $str =~ s/( +)/($rem-- > 0 ? " " : "") . $1;/eg
Truth table0%0/3
A and B
A= $rem > 0B= $str =~ s/( +)/($rem-- > 0 ? " " : "") . $1;/eg
ABresult
0X0
100
111
306 0 $_[0] = reverse $str;
307 }
308 0 &jleft;
309 }
310  
311 0 ▶ sub jsingle {
Subroutine jsingle: not called CC=2 SCAR=17.9
Pod undocumented
312 0 my (undef, %val) = @_;
313 0 ▶ $_[0] = length $_[0] ? substr($_[0],0,1) : fillpat($val{pos}, $val{pre},1);
Branch: 1 branch
BranchTrueFalseTotal
length $_[0] ? : 0 0 0
314 }
315  
316 0 ▶ sub jfatal {
Subroutine jfatal: not called CC=1 SCAR=6.9
Pod undocumented
317 0 die "Internal error in &form."
318 }
319  
320 0 ▶ sub joverflow (\%\%) {
Subroutine joverflow: not called CC=1 SCAR=6.9
Pod undocumented
321 0 $_[0]{overflow} = 1;
322 0 %{$_[1]} = ();
323 0 return \&jfatal;
324 }
325  
326 0 ▶ sub jbullet {
Subroutine jbullet: not called CC=1 SCAR=6.9
Pod undocumented
327 0 return ($_[0],1);
328 }
329  
330 22 ▶ sub jnum {
Subroutine jnum: called CC=23 SCAR=36.0
Pod undocumented
331 22 my ($fld,$precurr,$incurr,$postcurr,$width,$opts,$setplaces,$checkplaces)
332 = @_;
333 22 my $orig = $fld;
334 22 ▶ $incurr ||= qr/(?!)/;
Condition50%1/2
$incurr ||= qr/(?!)/
l!l
022
MC/DC0%0/1
$incurr ||= qr/(?!)/
$incurr
Truth table50%1/2
A
A= $incurr
Aresult
11
00
335  
336 22 my $comma_count = $fld=~tr/,//;
337 22 my $period_count = $fld=~tr/.//;
338 22 my $apost_count = $fld=~tr/ '//;
339 22 ▶ my $integral = $comma_count > 1 && !($period_count || $apost_count)
Condition41%10/24
$comma_count > 1 && !($period_count || $apost_count) || $period_count > 1 && !($comma_count || $apost_count) || $apost_count > 1 && !($comma_count || $period_count)
l!l&&r!l&&!r
1507
$comma_count > 1 and not $period_count || $apost_count or $period_count > 1 and not $comma_count || $apost_count
l!l&&r!l&&!r
1507
$comma_count > 1 and not $period_count || $apost_count
!ll&&!rl&&r
0715
$period_count || $apost_count
l!l&&r!l&&!r
7015
$period_count > 1 and not $comma_count || $apost_count
!ll&&!rl&&r
700
$comma_count || $apost_count
l!l&&r!l&&!r
000
$apost_count > 1 and not $comma_count || $period_count
!ll&&!rl&&r
700
$comma_count || $period_count
l!l&&r!l&&!r
000
MC/DC11%1/9
$comma_count > 1 && !($period_count || $apost_count) || $period_count > 1 && !($comma_count || $apost_count) || $apost_count > 1 && !($comma_count || $period_count)
$comma_count > 1 $period_count $apost_count $period_count > 1 $comma_count $apost_count $apost_count > 1 $comma_count $period_count
Truth table5%2/40
A and not(B || C) or D and not(E || F) || G and not(H || I)
A= $comma_count > 1B= $period_countC= $apost_countD= $period_count > 1E= $comma_countF= $apost_countG= $apost_count > 1H= $comma_countI= $period_count
ABCDEFGHIresult
100XXXXXX1
0XX100XXX1
11X100XXX1
101100XXX1
0XX0XX1001
0XX11X1001
0XX1011001
11X0XX1001
11X11X1001
11X1011001
1010XX1001
10111X1001
1011011001
0XX0XX0XX0
0XX0XX11X0
0XX0XX1010
0XX11X0XX0
0XX11X11X0
0XX11X1010
0XX1010XX0
0XX10111X0
0XX1011010
11X0XX0XX0
11X0XX11X0
11X0XX1010
11X11X0XX0
11X11X11X0
11X11X1010
11X1010XX0
11X10111X0
11X1011010
1010XX0XX0
1010XX11X0
1010XX1010
10111X0XX0
10111X11X0
10111X1010
1011010XX0
10110111X0
1011011010
340 || $period_count > 1 && !($comma_count || $apost_count)
341 || $apost_count > 1 && !($comma_count || $period_count);
342 22 ▶ my ($whole, $point, $places) =
Branch: 1 branch
BranchTrueFalseTotal
$integral ? : 15 7 22
343 $integral ? ($fld, "", "")
344 : ($fld =~ /^([]{>,.' 0]*)([.,]|\Q$incurr\E)([[}<0]*)/g);
345  
346 22 my $missing = $width-length($fld);
347 22 ▶ if ($missing>0) { $fld = substr($fld,0,1) x $missing . $fld }
Branch: 1 branch
BranchTrueFalseTotal
if ($missing > 0) 2 20 22
348  
349 22 ▶ $opts->{lfill} = '0' if $whole =~ m/^0+/;
Branch: 1 branch
BranchTrueFalseTotal
if $whole =~ /^0+/ 0 22 22
350 22 ▶ $opts->{rfill} = '0' if $places =~ m/0+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $places =~ /0+$/ 0 22 22
351 22 ▶ my $comma = $whole =~ /([,.' ])/ ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$whole =~ /([,.' ])/ ? : 22 0 22
352 22 my $grouping;
353 22 ▶ if ($comma) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comma) 22 0 22
354 22 ▶ $grouping = $whole =~ /,(?:\]{2},\]{3}|>{2},>{3})\z/ ? [3,2] # Subcont
Branch: 2 branches
BranchTrueFalseTotal
$whole =~ /,(?:\]{2},\]{3}|>{2},>{3})\z/ ? : 0 22 22
$whole =~ /[,.' ](\]+|>+)\z/ ? : 22 0 22
355 : $whole =~ /[,.' ](\]+|>+)\z/ ? [length($1)]
356 : undef;
357 }
358 22 ▶ if (defined $setplaces) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $setplaces) { } 8 14 22
359 8 $places = $setplaces;
360 8 $whole = $width - length($point) - $setplaces;
361 }
362 else {
363 14 $_ = length for $whole, $places;
364 }
365 22 ▶ fatal "Inconsistent number of decimal places in numeric field.\n",
Branch: 1 branch
BranchTrueFalseTotal
if $checkplaces and $places != $checkplaces 0 22 22
Condition33%1/3
$checkplaces and $places != $checkplaces
!ll&&!rl&&r
2200
MC/DC0%0/2
$checkplaces and $places != $checkplaces
$checkplaces $places != $checkplaces
Truth table33%1/3
A and B
A= $checkplacesB= $places != $checkplaces
ABresult
0X0
100
111
366 "Specified as $checkplaces but found $places"
367 if $checkplaces && $places != $checkplaces;
368 22 my $huh = substr( ('?'x$whole).$point.('?'x$places), 0, $width);
369 22 my $duh = substr( ('#'x$whole).$point.('#'x$places), 0, $width);
370  
371 22 $places -= length($postcurr);
372  
373 22 ▶ get_locale_vals($point, $comma, $grouping) if $opts->{locale};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"locale"} 0 22 22
374  
375 22 ▶ return sub {
Subroutine __ANON__: called CC=28 SCAR=38.0
376 22 my ($orig, %val) = @_;
377 22 ▶ $_[0] = " "x$val{width} and return if $orig =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $orig =~ /^\s*$/ 0 22 22
Condition20%1/5
$orig =~ /^\s*$/ && (($_[0] = ' ' x $val{'width'}) && (return))
!ll&&!rl&&r
2200
$_[0] = " " x $val{"width"} and return
!ll
00
MC/DC0%0/2
$orig =~ /^\s*$/ && (($_[0] = ' ' x $val{'width'}) && (return))
$orig =~ /^\s*$/ $_[0] = " " x $val{"width"}
Truth table33%1/3
A && B
A= $orig =~ /^\s*$/B= $_[0] = " " x $val{"width"}
ABresult
0X0
100
111
378 22 ▶ $orig =~ s/,|\Q$incurr\E/./ if $point ne '.';
Branch: 1 branch
BranchTrueFalseTotal
if $point ne "." 15 7 22
379 22 my ($pre,$post) = ($precurr,$postcurr);
380 22 ▶ if ($orig !~ /^\s*-/ || $orig == -$orig) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $orig =~ /^\s*-/ or $orig == -$orig) 0 22 22
Condition33%1/3
not $orig =~ /^\s*-/ or $orig == -$orig
l!l&&r!l&&!r
0022
MC/DC0%0/2
not $orig =~ /^\s*-/ or $orig == -$orig
not $orig =~ /^\s*-/ $orig == -$orig
Truth table33%1/3
not(A) or B
A= not $orig =~ /^\s*-/B= $orig == -$orig
ABresult
1X1
011
000
381 0 $pre =~ s/^[(-]|[(-]$/ /g;
382 0 $post =~ s/^[)-]|[)-]$/ /g;
383 }
384 22 my ($fail, $str);
385 22 my ($w, $p);
386 22 ▶ if ($integral) {
Branch: 1 branch
BranchTrueFalseTotal
if ($integral) { } 15 7 22
387 0 ▶ local $SIG{__WARN__} = sub { $fail = 1 };
Subroutine __ANON__: not called CC=1 SCAR=1.2
388 15 $str = sprintf('%*d',$val{width},int($orig));
389 15 ($w,$p) = ($str =~ /^\s*(.*)$/,""); # integer
390 }
391 else {
392 0 ▶ local $SIG{__WARN__} = sub { $fail = 1 };
Subroutine __ANON__: not called CC=1 SCAR=1.2
393 7 $str = sprintf('%*.*f',$val{width},$places,$orig);
394 7 ($w,$p) = ($str =~ /^\s*(.*)\.(.*)$/g); # floating point
395 }
396 22 ▶ if ($fail) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fail) { } 0 22 22
397 0 $_[0] = $huh;
398 }
399 else {
400 22 ▶ if ($grouping) {
Branch: 1 branch
BranchTrueFalseTotal
if ($grouping) 22 0 22
401 22 my @groups = @$grouping;
402 22 my $group = shift @groups;
403 22 ▶ if ($group) {
Branch: 1 branch
BranchTrueFalseTotal
if ($group) 22 0 22
404 22 $w =~ s/(\d)(\d{$group})\z/$1$comma$2/;
405 22 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$group and $w =~ s/(?<!,)(\d)(\d{$group})(?!\d)/$1$comma$2/ and do { do { $group = shift @groups if @groups } } 0 22 22
Condition33%1/3
$group and $w =~ s/(?<!,)(\d)(\d{$group})(?!\d)/$1$comma$2/
!ll&&!rl&&r
0220
MC/DC0%0/2
$group and $w =~ s/(?<!,)(\d)(\d{$group})(?!\d)/$1$comma$2/
$group $w =~ s/(?<!,)(\d)(\d{$group})(?!\d)/$1$comma$2/
Truth table33%1/3
A and B
A= $groupB= $w =~ s/(?<!,)(\d)(\d{$group})(?!\d)/$1$comma$2/
ABresult
0X0
100
111
406 22 ▶ $group = shift @groups if @groups;
Branch: 1 branch
BranchTrueFalseTotal
if @groups 0 22 22
407 } while $group && $w =~ s/(?<!,)(\d)(\d{$group})(?!\d)/$1$comma$2/;
408 }
409 }
410 22 ▶ if (length($w) > $width || !$val{stretch} && ($w ? length($w) : 0)+length($pre) > $whole) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $w > $width or not $val{'stretch'} and ($w ? length $w : 0) + length($pre) > $whole) { } 4 18 22
$w ? : 20 0 20
Condition83%5/6
length $w > $width or not $val{"stretch"} and ($w ? length $w : 0) + length($pre) > $whole
l!l&&r!l&&!r
2218
not $val{"stretch"} and ($w ? length $w : 0) + length($pre) > $whole
!ll&&!rl&&r
0182
MC/DC66%2/3
length $w > $width or not $val{"stretch"} and ($w ? length $w : 0) + length($pre) > $whole
length $w > $width not $val{"stretch"} ($w ? length $w : 0) + length($pre) > $whole
Truth table75%3/4
A or not(B) and C
A= length $w > $widthB= not $val{"stretch"}C= ($w ? length $w : 0) + length($pre) > $whole
ABCresult
1XX1
0111
00X0
0100
411 4 $_[0] = $duh;
412 }
413 else {
414 18 ▶ $str = $integral ? $w : $w.q(.).$p;
Branch: 1 branch
BranchTrueFalseTotal
$integral ? : 14 4 18
415 18 ▶ $str =~ s/(\.\d+?)(0+)$/$1/
Branch: 1 branch
BranchTrueFalseTotal
unless $orig =~ /\.\d\{$places,\}[1-9]/ 18 0 18
416 unless $orig =~ /\.\d\{$places,\}[1-9]/;
417 18 ▶ if ($integral && $str < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($integral and $str < 0) 14 4 18
Condition66%2/3
$integral and $str < 0
!ll&&!rl&&r
4014
MC/DC50%1/2
$integral and $str < 0
$integral $str < 0
Truth table66%2/3
A and B
A= $integralB= $str < 0
ABresult
0X0
100
111
418 14 ▶ if ($pre =~ /[(]/ || $post =~ /[)]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre =~ /[(]/ or $post =~ /[)]/) { } 2 12 14
Condition66%2/3
$pre =~ /[(]/ or $post =~ /[)]/
l!l&&r!l&&!r
2012
MC/DC50%1/2
$pre =~ /[(]/ or $post =~ /[)]/
$pre =~ /[(]/ $post =~ /[)]/
Truth table66%2/3
A or B
A= $pre =~ /[(]/B= $post =~ /[)]/
ABresult
1X1
011
000
419 2 $str =~ s/-//;
420 }
421 else {
422 12 s/-/ / for $pre, $post;
423 }
424 }
425 18 $str =~ s/^(?:\Q$pre\E)?/$pre/;
426 18 ▶ if ($val{pre} =~ /^0+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val{"pre"} =~ /^0+$/) 0 18 18
427 0 $str =~ s{^((\D*)(\d.*))\.}
428 0 {$2 . ("0" x max(0,$whole-length $1)) . "$3."}e;
429 0 $val{pre} = " ";
430 }
431 18 my $postlen = length($post);
432 18 ▶ if (!$integral) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($integral) 4 14 18
433 4 $str =~ s/^(.*)\./$1$point/;
434 4 my $width = $val{width}-$whole+length($1);
435 4 jleft($str, %val, width=>$width, precropped=>1);
436 4 jright($str, %val, precropped=>1);
437 }
438 18 ▶ if ($integral) {
Branch: 2 branches
BranchTrueFalseTotal
if ($integral) { } 14 4 18
elsif ($postlen) { } 0 4 4
439 14 $str = substr((q{ } x max(0,$width)) . $str . $post, -$width);
440 14 $str =~ s/(?:[ ]{$postlen}([ ]*))$/$post$+/;
441 }
442 elsif ($postlen) {
443 0 $str =~ s/(?:[ ]{$postlen}([ ]*)|.{$postlen}())$/$post$+/;
444 }
445 18 $_[0] = $str;
446 }
447 }
448 }
449 22 }
450  
451  
452 # Vertical justifiers
453  
454 44 ▶sub jverlit {
Subroutine jverlit: called CC=3 SCAR=11.1
Pod undocumented
455 44 my ($height, $above, $below, $column) = @_;
456 44 ▶ push @$column, ($column->[0]||"") while @$column < $height;
Branch: 1 branch
BranchTrueFalseTotal
@$column < $height and do { push @$column, $column->[0] || "" } 22 44 66
Condition50%1/2
$column->[0] || ''
l!l
022
MC/DC0%0/1
$column->[0] || ''
$column->[0]
Truth table50%1/2
A
A= $column->[0]
Aresult
11
00
457 }
458  
459 0 ▶sub jmiddle {
Subroutine jmiddle: not called CC=1 SCAR=6.9
Pod undocumented
460 0 my ($height, $above, $below, $column) = @_;
461 0 my $add = int(($height-@$column)/2);
462 0 splice @$column, 0, 0, ($above)x$add;
463 0 $add = $height-@$column;
464 0 push @$column, ($below)x$add;
465 }
466  
467 0 ▶sub jbottom {
Subroutine jbottom: not called CC=1 SCAR=6.9
Pod undocumented
468 0 my ($height, $above, $below, $column) = @_;
469 0 my $pre = $height-@$column;
470 0 splice @$column, 0, 0, ($above)x$pre;
471 }
472  
473 22 ▶sub jtop {
Subroutine jtop: called CC=1 SCAR=0.0
Pod undocumented
474 22 my ($height, $above, $below, $column) = @_;
475 22 my $post = $height-@$column;
476 22 push @$column, ($below)x$post;
477 }
478  
479  
480 2 my $precurrpat = qr/^(\{) ([^]0>[<,']+?) ([]>,'0])/x;
481 2 my $incurrpat = qr/([]>0]) ([^]0>[<,'. ]+?) ([[<0]) /x;
482 2 my $postcurrpat = qr/([[<>0]) ([^]0>[<]+) (\}$) /x;
483  
484 0 ▶sub perl6_match {
Subroutine perl6_match: not called CC=2 SCAR=12.2
Pod undocumented
485 0 my ($str, $pat) = @_;
486 2 ▶ use re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
487 0 ▶ if (my @vals = $str =~ /$pat/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@vals) = $str =~ /$pat/) { } 0 0 0
488 0 unshift @vals, $&;
489 0 bless \@vals, 'Perl6::Form::Rule::Okay';
490 }
491 else {
492 0 bless [], 'Perl6::Form::Rule::Fail';
493 }
494 }
495  
496 2 my $litval;
497 66 ▶sub litval {
Subroutine litval: called CC=2 SCAR=6.9
Pod undocumented
498 66 ▶ ($litval) = @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 44 22 66
499 66 return $litval;
500 }
501  
502 2 my ($fld, $udnum);
503 44 ▶sub fldvals {
Subroutine fldvals: called CC=2 SCAR=6.9
Pod undocumented
504 44 ▶ ($fld, $udnum) = @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 22 22 44
505 44 return ($fld, $udnum);
506 }
507  
508 2 our $nestedbraces = qr/ \{ (?: (?> ((?!\{|\}).)+ ) | (??{ $nestedbraces }) )* \} /sx;
509  
510 22 ▶sub segment ($\@\%$\%) {
Subroutine segment: called CC=97 SCAR=70.3
Pod undocumented
511 22 my ($format, $args, $opts, $fldcnt, $argcache) = @_;
512 my $width =
513 22 ▶ defined $opts->{page}{width} ? $opts->{page}{width} : length($format);
Branch: 1 branch
BranchTrueFalseTotal
defined $opts->{'page'}{'width'} ? : 22 0 22
514 22 ▶ my $userdef = join("|", @{$opts->{field}{from}}) || qr/(?!)/;
Condition50%1/2
join('|', @{$opts->{'field'}{'from'};}) || qr/(?!)/
l!l
022
MC/DC0%0/1
join('|', @{$opts->{'field'}{'from'};}) || qr/(?!)/
join('|', @{$opts->{'field'}{'from'};})
Truth table50%1/2
A
A= join('|', @{$opts->{'field'}{'from'};})
Aresult
11
00
515 22 ▶ my $bullet = join("|", map quotemeta, @{$opts->{bullet}}) || qr/(?!)/;
Condition50%1/2
join('|', map(quotemeta($_), @{$$opts{'bullet'};})) || qr/(?!)/
l!l
022
MC/DC0%0/1
join('|', map(quotemeta($_), @{$$opts{'bullet'};})) || qr/(?!)/
join('|', map(quotemeta($_), @{$$opts{'bullet'};}))
Truth table50%1/2
A
A= join('|', map(quotemeta($_), @{$$opts{'bullet'};}))
Aresult
11
00
516 2 ▶ use re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
517 22 my @format;
518 22 ▶ while ($format =~ /\G ((?>(?:\\.|(?!$userdef|$bullet|\{).)*))
Branch: 1 branch
BranchTrueFalseTotal
if ($format =~ /\G ((?>(?:\\.|(?!$userdef|$bullet|\{).)*)) (?{ litval($^N); }) (?: ($userdef) (?{ fldvals($^N, $^R); }) | ($bullet) (?{ fldvals($^N, -1); }) | ($nestedbraces) (?{ fldvals($^N, undef); }) ) /cgsx) 22 22 44
519 44 (?{litval($^N)})
520 0 (?: ($userdef) (?{fldvals($^N,$^R)})
521 0 | ($bullet) (?{fldvals($^N,-1)})
522 22 | ($nestedbraces) (?{fldvals($^N,undef)})
523 )
524 /gcsx) {
525 22 push @format, litval(), fldvals();
526 }
527 22 ▶ push @format, substr ($format, pos($format)||0);
Condition50%1/2
pos $format || 0
l!l
220
MC/DC0%0/1
pos $format || 0
pos $format
Truth table50%1/2
A
A= pos $format
Aresult
11
00
528 22 my $args_req = int(@format/3);
529 22 my (@formatters,@starred,@vstarred);
530 22 for my $i (0..$args_req) {
531 44 my ($literal,$field,$userdef) = @format[3*$i..3*$i+2];
532 44 $literal =~ s/\\\{/{/g;
533 44 push @formatters, { %std_literal,
534 width => length($literal),
535 src => \$literal,
536 };
537 44 $width -= length($literal);
538 44 ▶ if (defined $field) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $field) 22 22 44
539 22 my %form;
540 22 my %fldopts = %$opts;
541 22 $fldcnt++;
542 22 my ($setwidth, $setplaces, $checkwidth, $checkplaces);
543 22 ▶ if (defined $userdef) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $userdef) 0 22 22
544 0 ▶ if ($userdef < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($userdef < 0) { } 0 0 0
545 0 $form{isbullet} = \"$field";
546 }
547 else {
548 my ($from,$to) =
549 0 map $_->[$userdef], @{$opts->{field}}{'from','to'};
550 0 $field = $to->(perl6_match($field,$from),\%fldopts);
551 }
552 }
553 22 my $fld = $field;
554 22 my ($precurr, $incurr, $postcurr) = ("")x3;
555 22 $form{width} = length $field;
556 22 ▶ if ($form{isbullet}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form{'isbullet'}) { } 0 22 22
557 0 $form{vjust} = \&jtop;
558 0 $form{hjust} = \&jbullet;
559 0 $form{break} = \&break_bullet;
560 0 $form{src} = [];
561 0 ($form{bullethole} = $field) =~ s/./ /gs;
562 }
563 else {
564 22 ▶ $form{stretch} = !$form{isbullet} && $fld =~ s/[+]//;
Condition33%1/3
!$form{'isbullet'} && $fld =~ s/[+]//
!ll&&!rl&&r
0220
MC/DC0%0/2
!$form{'isbullet'} && $fld =~ s/[+]//
!$form{'isbullet'} $fld =~ s/[+]//
Truth table33%1/3
not(A) && B
A= !$form{'isbullet'}B= $fld =~ s/[+]//
ABresult
0X0
100
111
565 22 ▶ @form{qw(verbatim break hjust)}
Branch: 1 branch
BranchTrueFalseTotal
if $fld =~ /["']/ and not $fld =~ /[][><]/ 0 22 22
Condition33%1/3
$fld =~ /["']/ and not $fld =~ /[][><]/
!ll&&!rl&&r
2200
MC/DC0%0/2
$fld =~ /["']/ and not $fld =~ /[][><]/
$fld =~ /["']/ not $fld =~ /[][><]/
Truth table33%1/3
A and not(B)
A= $fld =~ /["']/B= not $fld =~ /[][><]/
ABresult
0X0
100
111
566 = (1, \&break_verbatim, \&jverbatim)
567 if $fld =~ /["']/ && $fld !~ /[][><]/;
568 # was: if $fld =~ /["']/ && $fld !~ /[][]/;
569 22 $form{trackpos} = $fld =~ s/(\{):|:(\})/$+/g;
570 22 ▶ $form{vjust} = $fld =~ s/=//g ? \&jmiddle
Branch: 2 branches
BranchTrueFalseTotal
$fld =~ s/=//g ? : 0 22 22
$fld =~ s/_//g ? : 0 22 22
571 : $fld =~ s/_//g ? \&jbottom
572 : \&jtop
573 ;
574  
575 22 ($checkwidth, $extras) = $fld =~ m/\(\s*(\d+[.,]?\d*)\s*\)/g;
576 22 ▶ fatal "Too many width specifications in $field" if $extras;
Branch: 1 branch
BranchTrueFalseTotal
if $extras 0 22 22
577 22 ▶ if ($checkwidth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($checkwidth) 0 22 22
578 0 ▶ $checkplaces = $checkwidth =~ s/[.,](\d+)// && $1;
Condition0%0/3
$checkwidth =~ s/[.,](\d+)// && $1
!ll&&!rl&&r
000
MC/DC0%0/2
$checkwidth =~ s/[.,](\d+)// && $1
$checkwidth =~ s/[.,](\d+)// $1
Truth table0%0/3
A && B
A= $checkwidth =~ s/[.,](\d+)//B= $1
ABresult
0X0
100
111
579 0 for ($fld) {
580 0 ▶ s{([][><I|Vv"']) (\(\s*\d+[.,]?\d*\s*\))}
Branch: 1 branch
BranchTrueFalseTotal
s/([][><I|Vv"']) (\(\s*\d+[.,]?\d*\s*\))/$1 . $1 x length($2);/ex and last 0 0 0
581 0 { $1 . ($1 x length $2) }xe and last;
582 0 ▶ s{(\(\s*\d+[.,]?\d*\s*\)) ([][><I|V"'])}
Branch: 1 branch
BranchTrueFalseTotal
s/(\(\s*\d+[.,]?\d*\s*\)) ([][><I|V"'])/$2 x length($1) . $2;/ex and last 0 0 0
583 0 { ($2 x length $1) . $2 }xe and last;
584 0 ▶ s{(> [.,]) (\(\s*\d+[.,]?\d*\s*\))}
Branch: 1 branch
BranchTrueFalseTotal
s/(> [.,]) (\(\s*\d+[.,]?\d*\s*\))/$1 . "<" x length($2);/ex and last 0 0 0
585 0 { $1 . ('<' x length $2) }xe and last;
586 0 ▶ s{(\(\s*\d+[.,]?\d*\s*\)) ([.,] <)}
Branch: 1 branch
BranchTrueFalseTotal
s/(\(\s*\d+[.,]?\d*\s*\)) ([.,] <)/">" x length($1) . $2;/ex and last 0 0 0
587 0 { ('>' x length $1) . $2 }xe and last;
588 0 ▶ s{(\(\s*\d+[.,]?\d*\s*\)) ([.,] \[)}
Branch: 1 branch
BranchTrueFalseTotal
s/(\(\s*\d+[.,]?\d*\s*\)) ([.,] \[)/"]" x length($1) . $2;/ex and last 0 0 0
589 0 { (']' x length $1) . $2 }xe and last;
590 0 ▶ s{(\(\s*\d+[.,]?\d*\s*\))}
Branch: 1 branch
BranchTrueFalseTotal
s/(\(\s*\d+[.,]?\d*\s*\))/"[" x length($1);/ex and last 0 0 0
591 0 { '[' x length $1 }xe and last;
592 }
593 }
594  
595 22 ▶ ($setwidth, $extras) = $fld =~ m/\{\s*(\d+[.,]?\d*|\*)\s*\}/g
Branch: 1 branch
BranchTrueFalseTotal
($setwidth, $extras) = $fld =~ /\{\s*(\d+[.,]?\d*|\*)\s*\}/g and $fld =~ s/\{\s*(\d+[.,]?\d*|\*)\s*\}// 16 6 22
596 and $fld =~ s/\{\s*(\d+[.,]?\d*|\*)\s*\}//;
597 22 ▶ fatal "Too many width specifications in $field"
Branch: 1 branch
BranchTrueFalseTotal
if $extras or $setwidth and $checkwidth 0 22 22
Condition50%3/6
$extras or $setwidth and $checkwidth
l!l&&r!l&&!r
0022
$setwidth and $checkwidth
!ll&&!rl&&r
6160
MC/DC0%0/3
$extras or $setwidth and $checkwidth
$extras $setwidth $checkwidth
Truth table50%2/4
A or B and C
A= $extrasB= $setwidthC= $checkwidth
ABCresult
1XX1
0111
00X0
0100
598 if $extras || $setwidth && $checkwidth;
599 22 ▶ if ($setwidth && $setwidth =~ s/[.,](\d+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($setwidth and $setwidth =~ s/[.,](\d+)//) 8 14 22
Condition100%3/3
$setwidth and $setwidth =~ s/[.,](\d+)//
!ll&&!rl&&r
688
MC/DC100%2/2
$setwidth and $setwidth =~ s/[.,](\d+)//
$setwidth $setwidth =~ s/[.,](\d+)//
Truth table100%3/3
A and B
A= $setwidthB= $setwidth =~ s/[.,](\d+)//
ABresult
0X0
100
111
600 8 ▶ $setplaces = $1 || 0;
Condition100%2/2
$1 || 0
l!l
71
MC/DC100%1/1
$1 || 0
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
601 }
602  
603 22 for ([$checkwidth, $checkplaces], [$setwidth, $setplaces]) {
604 44 ▶ fatal "Can't fit $_->[1] decimal place",($_->[1]!=1?'s':''),
Branch: 2 branches
BranchTrueFalseTotal
if defined $_->[0] and defined $_->[1] and $_->[0] ne "*" and $_->[0] <= $_->[1] 0 44 44
$_->[1] != 1 ? : 0 0 0
Condition77%7/9
defined $_->[0] and defined $_->[1] and $_->[0] ne "*" and $_->[0] <= $_->[1]
!ll&&!rl&&r
3680
defined $_->[0] and defined $_->[1] and $_->[0] ne "*"
!ll&&!rl&&r
3608
defined $_->[0] and defined $_->[1]
!ll&&!rl&&r
2888
MC/DC0%0/4
defined $_->[0] and defined $_->[1] and $_->[0] ne "*" and $_->[0] <= $_->[1]
defined $_->[0] defined $_->[1] $_->[0] ne "*" $_->[0] <= $_->[1]
Truth table60%3/5
A and B and C and D
A= defined $_->[0]B= defined $_->[1]C= $_->[0] ne "*"D= $_->[0] <= $_->[1]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
605 " in a $_->[0]-character field"
606 if defined($_->[0]) && defined($_->[1])
607 && $_->[0] ne '*'
608 && $_->[0] <= $_->[1];
609 }
610  
611 $precurr =
612 22 ▶ $fld =~ s/$precurrpat/$1.($3 x length $2).$3/e ? "$2" : "";
Branch: 1 branch
BranchTrueFalseTotal
$fld =~ s/$precurrpat/$1 . $3 x length($2) . $3;/e ? : 5 17 22
613 22 ▶ $incurr =
Branch: 1 branch
BranchTrueFalseTotal
$fld =~ /$incurrpat/ ? : 0 22 22
614 $fld =~ m/$incurrpat/ ? "$2" : "";
615 22 ▶ $postcurr =
Branch: 1 branch
BranchTrueFalseTotal
$fld =~ s/$postcurrpat/$1 . $1 x length($2) . $3;/e ? : 2 20 22
616 2 $fld =~ s/$postcurrpat/$1.($1 x length $2).$3/e ? "$2" : "";
617  
618 22 ▶ if ($form{width} == 2) {
Branch: 3 branches
BranchTrueFalseTotal
if ($form{'width'} == 2) { } 0 22 22
elsif ($form{'width'} == 3) { } 0 22 22
elsif ($form{'width'} > 3) { } 22 0 22
619 0 $fld = '[[';
620 }
621 elsif ($form{width} == 3) {
622 0 $fld =~ s/^ \{ ([.,]) \} $/].[/x;
623 0 $fld =~ s/^ \{ (.) \} $/$+$+$+/x;
624 }
625 elsif ($form{width} > 3) {
626 22 $fld =~ s/^ \{ ([]>,]+ ([]>])) \} $/$2$2$1/x; # Integral comma'd field
627 22 $fld =~ s/^ \{ ([.,] \[) /]$1/x;
628 22 $fld =~ s/^ \{ ([.,] \<) />$1/x;
629 22 $fld =~ s/(\] .* [.,]) \} $/$1\[/x;
630 22 $fld =~ s/(\> .* [.,]) \} $/$1</x;
631 22 $fld =~ s/^ \{ (.) | (.) \} $/$+$+/gx;
632 }
633  
634 22 ▶ $form{width} = $setwidth
Branch: 1 branch
BranchTrueFalseTotal
if defined $setwidth and $setwidth ne "*" 16 6 22
Condition66%2/3
defined $setwidth and $setwidth ne "*"
!ll&&!rl&&r
6016
MC/DC50%1/2
defined $setwidth and $setwidth ne "*"
defined $setwidth $setwidth ne "*"
Truth table66%2/3
A and B
A= defined $setwidthB= $setwidth ne "*"
ABresult
0X0
100
111
635 if defined $setwidth && $setwidth ne '*';
636  
637 22 ▶ if ($form{width} == 2) {
Branch: 3 branches
BranchTrueFalseTotal
if ($form{'width'} == 2) { } 0 22 22
elsif ($form{'width'} == 3) { } 0 22 22
elsif ($form{'width'} > 3) { } 22 0 22
638 0 $fld = substr($fld,0,1) x 2;
639 }
640 elsif ($form{width} == 3) {
641 0 $fld =~ s/^ \{ ([.,]) \} $/].[/x;
642 0 $fld =~ s/^ \{ (.) \} $/$+$+$+/x;
643 }
644 elsif ($form{width} > 3) {
645 22 $fld =~ s/^ \{ ([.,] \[) /]$1/x;
646 22 $fld =~ s/^ \{ ([.,] \<) />$1/x;
647 22 $fld =~ s/(\] .* [.,]) \} $/$1\[/x;
648 22 $fld =~ s/(\> .* [.,]) \} $/$1</x;
649 22 $fld =~ s/^ \{ (.) | (.) \} $/$+$+/gx;
650 }
651  
652 22 ▶ $form{width} = $setwidth
Branch: 1 branch
BranchTrueFalseTotal
if defined $setwidth and $setwidth ne "*" 16 6 22
Condition66%2/3
defined $setwidth and $setwidth ne "*"
!ll&&!rl&&r
6016
MC/DC50%1/2
defined $setwidth and $setwidth ne "*"
defined $setwidth $setwidth ne "*"
Truth table66%2/3
A and B
A= defined $setwidthB= $setwidth ne "*"
ABresult
0X0
100
111
653 if defined $setwidth && $setwidth ne '*';
654 }
655  
656 22 ▶ if ($setwidth && $setwidth eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($setwidth and $setwidth eq '*') { } 0 22 22
Condition66%2/3
$setwidth and $setwidth eq "*"
!ll&&!rl&&r
6160
MC/DC0%0/2
$setwidth and $setwidth eq "*"
$setwidth $setwidth eq "*"
Truth table66%2/3
A and B
A= $setwidthB= $setwidth eq "*"
ABresult
0X0
100
111
657 0 ▶ push @{$form{verbatim} ? \@vstarred : \@starred}, \%form;
Branch: 1 branch
BranchTrueFalseTotal
$form{'verbatim'} ? : 0 0 0
658 }
659 else {
660 $width -= $form{width}
661 22 }
662  
663 22 ▶ $form{line} = 1 unless $form{isbullet} || $fld =~ /[][IV"]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $form{"isbullet"} or $fld =~ /[][IV"]/ 22 0 22
Condition33%1/3
$form{"isbullet"} or $fld =~ /[][IV"]/
l!l&&r!l&&!r
0022
MC/DC0%0/2
$form{"isbullet"} or $fld =~ /[][IV"]/
$form{"isbullet"} $fld =~ /[][IV"]/
Truth table33%1/3
A or B
A= $form{"isbullet"}B= $fld =~ /[][IV"]/
ABresult
1X1
011
000
664  
665 $form{hjust} ||= $form{width} == 1 ? \&jsingle
666 : ($fld =~ /^(?:<+|\[+)$/) ? \&jleft
667 : ($fld =~ /^(?:>+|\]+)$/) ? \&jright
668 : ($fld =~ /^(?:I+|\|+|>+<+|\]+\[+)$/)? \&jcentre
669 : ($fld =~ /^(?:<+>+|\[+\]+)$/) ? \&jfull
670 : ($fld =~ /^(?:V+)$/) ? joverflow(%form, %fldopts)
671 : ($fld =~ /^(?: [>,' 0]* \. [<0]*
672 | [],' 0]* \. [[0]*
673 | [>.' 0]* \, [<0]*
674 | [].' 0]* \, [[0]*
675 | [>.,' 0]* \Q$incurr\E [<0]*
676 | [].,' 0]* \Q$incurr\E [[0]*
677 | [].' 0]* \, [[0]*
678 22 ▶ )$/x) ? do {
Branch: 7 branches
BranchTrueFalseTotal
$form{'width'} == 1 ? : 0 22 22
$fld =~ /^(?:<+|\[+)$/ ? : 0 22 22
$fld =~ /^(?:>+|\]+)$/ ? : 0 22 22
$fld =~ /^(?:I+|\|+|>+<+|\]+\[+)$/ ? : 0 22 22
$fld =~ /^(?:<+>+|\[+\]+)$/ ? : 0 22 22
$fld =~ /^(?:V+)$/ ? : 0 22 22
$fld =~ /^(?: [>,' 0]* \. [<0]* | [],' 0]* \. [[0]* | [>.' 0]* \, [<0]* | [].' 0]* \, [[0]* | [>.,' 0]* \Q$incurr\E [<0]* | [].,' 0]* \Q$incurr\E [[0]* | [].' 0]* \, [[0]* )$/x ? : 22 0 22
Condition33%1/3
$form{"hjust"} ||= $form{"width"} == 1 ? \&jsingle : ($fld =~ /^(?:<+|\[+)$/ ? \&jleft : ($fld =~ /^(?:>+|\]+)$/ ? \&jright : ($fld =~ /^(?:I+|\|+|>+<+|\]+\[+)$/ ? \&jcentre : ($fld =~ /^(?:<+>+|\[+\]+)$/ ? \&jfull : ($fld =~ /^(?:V+)$/ ? &joverflow(\%form, \%fldopts) : ($fld =~ /^(?: [>,' 0]* \. [<0]* | [],' 0]* \. [[0]* | [>.' 0]* \, [<0]* | [].' 0]* \, [[0]* | [>.,' 0]* \Q$incurr\E [<0]* | [].,' 0]* \Q$incurr\E [[0]* | [].' 0]* \, [[0]* )$/x ? do { $form{"break"} = \&break_nl; jnum($fld, $precurr, $incurr, $postcurr, $form{"width"}, \%fldopts, $setplaces, $checkplaces) } : fatal("Field $fldcnt is of unknown type: $field")))))))
l!l&&r!l&&!r
0220
MC/DC0%0/2
$form{"hjust"} ||= $form{"width"} == 1 ? \&jsingle : ($fld =~ /^(?:<+|\[+)$/ ? \&jleft : ($fld =~ /^(?:>+|\]+)$/ ? \&jright : ($fld =~ /^(?:I+|\|+|>+<+|\]+\[+)$/ ? \&jcentre : ($fld =~ /^(?:<+>+|\[+\]+)$/ ? \&jfull : ($fld =~ /^(?:V+)$/ ? &joverflow(\%form, \%fldopts) : ($fld =~ /^(?: [>,' 0]* \. [<0]* | [],' 0]* \. [[0]* | [>.' 0]* \, [<0]* | [].' 0]* \, [[0]* | [>.,' 0]* \Q$incurr\E [<0]* | [].,' 0]* \Q$incurr\E [[0]* | [].' 0]* \, [[0]* )$/x ? do { $form{"break"} = \&break_nl; jnum($fld, $precurr, $incurr, $postcurr, $form{"width"}, \%fldopts, $setplaces, $checkplaces) } : fatal("Field $fldcnt is of unknown type: $field")))))))
$form{"hjust"} $form{"width"} == 1 ? \&jsingle : ($fld =~ /^(?:<+|\[+)$/ ? \&jleft : ($fld =~ /^(?:>+|\]+)$/ ? \&jright : ($fld =~ /^(?:I+|\|+|>+<+|\]+\[+)$/ ? \&jcentre : ($fld =~ /^(?:<+>+|\[+\]+)$/ ? \&jfull : ($fld =~ /^(?:V+)$/ ? &joverflow(\%form, \%fldopts) : ($fld =~ /^(?: [>,' 0]* \. [<0]* | [],' 0]* \. [[0]* | [>.' 0]* \, [<0]* | [].' 0]* \, [[0]* | [>.,' 0]* \Q$incurr\E [<0]* | [].,' 0]* \Q$incurr\E [[0]* | [].' 0]* \, [[0]* )$/x ? do { $form{"break"} = \&break_nl; jnum($fld, $precurr, $incurr, $postcurr, $form{"width"}, \%fldopts, $setplaces, $checkplaces) } : fatal("Field $fldcnt is of unknown type: $field")))))))
Truth table33%1/3
A ||= B
A= $form{"hjust"}B= $form{"width"} == 1 ? \&jsingle : ($fld =~ /^(?:<+|\[+)$/ ? \&jleft : ($fld =~ /^(?:>+|\]+)$/ ? \&jright : ($fld =~ /^(?:I+|\|+|>+<+|\]+\[+)$/ ? \&jcentre : ($fld =~ /^(?:<+>+|\[+\]+)$/ ? \&jfull : ($fld =~ /^(?:V+)$/ ? &joverflow(\%form, \%fldopts) : ($fld =~ /^(?: [>,' 0]* \. [<0]* | [],' 0]* \. [[0]* | [>.' 0]* \, [<0]* | [].' 0]* \, [[0]* | [>.,' 0]* \Q$incurr\E [<0]* | [].,' 0]* \Q$incurr\E [[0]* | [].' 0]* \, [[0]* )$/x ? do { $form{"break"} = \&break_nl; jnum($fld, $precurr, $incurr, $postcurr, $form{"width"}, \%fldopts, $setplaces, $checkplaces) } : fatal("Field $fldcnt is of unknown type: $field")))))))
ABresult
1X1
011
000
679 22 $form{break}=\&break_nl;
680 jnum($fld,$precurr,$incurr,$postcurr,
681 22 $form{width},\%fldopts,
682 $setplaces, $checkplaces)
683 }
684 : fatal "Field $fldcnt is of unknown type: $field"
685 ;
686  
687 22 ▶ $form{break}=\&break_nl if $form{stretch};
Branch: 1 branch
BranchTrueFalseTotal
if $form{"stretch"} 0 22 22
688  
689 fatal "Inconsistent width for field $fldcnt.\n",
690 "Specified as '$field' but actual width is $form{width}"
691 22 ▶ if defined $checkwidth && $form{width} != $checkwidth;
Branch: 1 branch
BranchTrueFalseTotal
if defined $checkwidth and $form{"width"} != $checkwidth 0 22 22
Condition33%1/3
defined $checkwidth and $form{"width"} != $checkwidth
!ll&&!rl&&r
2200
MC/DC0%0/2
defined $checkwidth and $form{"width"} != $checkwidth
defined $checkwidth $form{"width"} != $checkwidth
Truth table33%1/3
A and B
A= defined $checkwidthB= $form{"width"} != $checkwidth
ABresult
0X0
100
111
692  
693 22 ▶ splice @$args, $i, 0, "" if $form{isbullet}; # BEFORE ANY OPTIONS
Branch: 1 branch
BranchTrueFalseTotal
if $form{"isbullet"} 0 22 22
694  
695 22 ▶ while (ref $args->[$i] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args->[$i] eq "HASH") 0 22 22
696 0 update %fldopts, %{splice @$args, $i, 1};
697 }
698 22 $form{opts} = \%fldopts;
699  
700 22 ▶ splice @$args, $i, 0, "" if $form{overflow}; # AFTER ANY OPTIONS
Branch: 1 branch
BranchTrueFalseTotal
if $form{"overflow"} 0 22 22
701  
702 22 ▶ fatal "Missing data value for field ", $i, " ($field)"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args->[$i] 0 22 22
703 unless defined $args->[$i];
704  
705 22 for ($args->[$i]) {
706 22 ▶ next if $form{isbullet};
Branch: 1 branch
BranchTrueFalseTotal
if $form{"isbullet"} 0 22 22
707 $form{src} ||=
708 ref eq 'ARRAY' ? do {
709 0 my $s = join "", map { my $val = $_; $val =~ s/\n(?!\z)/\r/g; $val }
710 0 ▶ map {!defined() ? "\n"
Branch: 2 branches
BranchTrueFalseTotal
!defined($_) ? : 0 0 0
/\n\z/ ? : 0 0 0
711 : /\n\z/ ? $_
712 : "$_\n"} @$_;
713 0 ▶ $form{trackpos} ? ($argcache->{$_} ||= \$s) : \$s;
Branch: 2 branches
BranchTrueFalseTotal
$form{'trackpos'} ? : 0 0 0
&readonly($_) || !$form{'trackpos'} ? : 22 0 22
Condition20%1/5
$argcache->{$_} ||= \$s
l!l
00
&readonly($_) or not $form{"trackpos"}
l!l&&r!l&&!r
0220
MC/DC0%0/1
$argcache->{$_} ||= \$s
$argcache->{$_}
MC/DC0%0/2
&readonly($_) or not $form{"trackpos"}
&readonly($_) not $form{"trackpos"}
Truth table0%0/2
A
A= $argcache->{$_}
Aresult
11
00
Truth table33%1/3
A or not(B)
A= &readonly($_)B= not $form{"trackpos"}
ABresult
1X1
011
000
714 }
715 22 ▶ : (readonly $_ || !$form{trackpos}) ? \(my$s=$_)
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 22 22
Condition33%1/3
$form{"src"} ||= ref $_ eq "ARRAY" ? do { my $s = join("", map({my $val = $_; $val =~ s/\n(?!\z)/\r/g; $val;} map({!defined($_) ? "\n" : (/\n\z/ ? $_ : "$_\n");} @$_))); $form{"trackpos"} ? $argcache->{$_} ||= \$s : \$s } : (&readonly($_) || !$form{"trackpos"} ? \(my $s = $_) : \$_)
l!l&&r!l&&!r
0220
MC/DC0%0/2
$form{"src"} ||= ref $_ eq "ARRAY" ? do { my $s = join("", map({my $val = $_; $val =~ s/\n(?!\z)/\r/g; $val;} map({!defined($_) ? "\n" : (/\n\z/ ? $_ : "$_\n");} @$_))); $form{"trackpos"} ? $argcache->{$_} ||= \$s : \$s } : (&readonly($_) || !$form{"trackpos"} ? \(my $s = $_) : \$_)
$form{"src"} ref $_ eq "ARRAY" ? do { my $s = join("", map({my $val = $_; $val =~ s/\n(?!\z)/\r/g; $val;} map({!defined($_) ? "\n" : (/\n\z/ ? $_ : "$_\n");} @$_))); $form{"trackpos"} ? $argcache->{$_} ||= \$s : \$s } : (&readonly($_) || !$form{"trackpos"} ? \(my $s = $_) : \$_)
Truth table33%1/3
A ||= B
A= $form{"src"}B= ref $_ eq "ARRAY" ? do { my $s = join("", map({my $val = $_; $val =~ s/\n(?!\z)/\r/g; $val;} map({!defined($_) ? "\n" : (/\n\z/ ? $_ : "$_\n");} @$_))); $form{"trackpos"} ? $argcache->{$_} ||= \$s : \$s } : (&readonly($_) || !$form{"trackpos"} ? \(my $s = $_) : \$_)
ABresult
1X1
011
000
716 : \$_;
717 }
718  
719 22 ▶ $form{break} ||= $fldopts{break} || $opts->{break};
Condition16%1/6
$form{"break"} ||= $fldopts{"break"} || $opts->{"break"}
l!l&&r!l&&!r
2200
$fldopts{'break'} || $opts->{'break'}
l!l&&r!l&&!r
000
MC/DC0%0/3
$form{"break"} ||= $fldopts{"break"} || $opts->{"break"}
$form{"break"} $fldopts{'break'} $opts->{'break'}
Truth table0%0/4
A ||= B || C
A= $form{"break"}B= $fldopts{'break'}C= $opts->{'break'}
ABCresult
1XX1
01X1
0011
0000
720  
721 22 push @formatters, \%form;
722 }
723 }
724 22 splice @$args, 0, $args_req;
725 22 $_[-1] = $fldcnt; # remember field count
726 # Distribute {*} widths...
727 22 for my $f (@vstarred) {
728 0 $f->{maxwidth} = max 0, map {length} split "\n", ${$f->{src}};
729 }
730 22 ▶ if (@starred||@vstarred) {
Branch: 1 branch
BranchTrueFalseTotal
if (@starred or @vstarred) 0 22 22
Condition33%1/3
@starred or @vstarred
l!l&&r!l&&!r
0022
MC/DC0%0/2
@starred or @vstarred
@starred @vstarred
Truth table33%1/3
A or B
A= @starredB= @vstarred
ABresult
1X1
011
000
731 0 my $fldwidth = int($width/(@starred+@vstarred));
732 0 for my $f (@vstarred) {
733 $f->{width} = @starred ? $f->{maxwidth}
734 0 ▶ : min $fldwidth, $f->{maxwidth};
Branch: 1 branch
BranchTrueFalseTotal
@starred ? : 0 0 0
735 0 $width += $fldwidth - $f->{width};
736 }
737 0 ▶ $fldwidth = int($width/(@starred+@vstarred)) if @starred;
Branch: 1 branch
BranchTrueFalseTotal
if @starred 0 0 0
738 0 $_->{width} = $fldwidth for @starred;
739 }
740  
741 # Attach bullets to neighbouring fields,
742 # and compute offsets from left margin...
743 22 my $offset = 0;
744 22 my $lastbullet;
745 22 for my $f (@formatters) {
746 66 $f->{pos} = $offset;
747 66 $offset += $f->{width};
748 66 ▶ if ($lastbullet) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastbullet) 0 66 66
749 0 ▶ if ($f->{literal}) { # IGNORE IT
Branch: 2 branches
BranchTrueFalseTotal
if ($f->{'literal'}) { } 0 0 0
elsif ($f->{'isbullet'}) { } 0 0 0
750 }
751 elsif ($f->{isbullet}) {
752 0 my $literal = ${$lastbullet->{isbullet}};
753 0 %$lastbullet = (%std_literal, width=>length($literal), src=>\$literal);
754 0 $lastbullet = undef;
755 }
756 else {
757 0 $f->{hasbullet} = $lastbullet;
758 0 $lastbullet = undef;
759 }
760 }
761 66 ▶ $lastbullet = $f if $f->{isbullet};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} 0 66 66
762 }
763 22 ▶ if ($lastbullet) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastbullet) 0 22 22
764 0 my $literal = ${$lastbullet->{isbullet}};
765 0 %$lastbullet = (%std_literal, width=>length($literal), src=>\$literal);
766 }
767  
768 22 return \@formatters;
769 }
770  
771 44 ▶sub layout_groups {
Subroutine layout_groups: called CC=4 SCAR=14.5
Pod undocumented
772 44 my @groups;
773 44 my $i = 0;
774 44 FORMATTER: for my $f (@_) {
775 66 $f->{index} = $i++;
776 66 for my $group (@groups) {
777 66 ▶ if ($f->{src} == $group->[0]{src}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f->{"src"} == $group->[0]{"src"}) 0 66 66
778 0 push @$group, $f;
779 0 next FORMATTER;
780 }
781 }
782 66 push @groups, [$f];
783 }
784 44 return @groups;
785 }
786  
787 66 ▶sub make_col {
Subroutine make_col: called CC=32 SCAR=52.6
Pod undocumented
788 66 my ($f, $opts, $maxheight, $tabular) = @_;
789 $maxheight = min $unlimited,
790 66 grep defined(), $maxheight, $f->{opts}{height}{max};
791 66 my ($str_ref, $width) = @{$f}{qw(src width)};
792 66 my @col;
793 66 my ($more, $text) = (1,"");
794 66 my $bullet = $f->{hasbullet};
795 66 ▶ $bullet->{bullets} = [] if $bullet;
Branch: 1 branch
BranchTrueFalseTotal
if $bullet 0 66 66
796 66 my $bulleted = 1;
797 66 ▶ until ($f->{done}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($f->{"done"}) 66 0 66
798 66 my $skipped = 0;
799 66 ▶ unless ($f->{isbullet} || $f->{width} == 1 || $f->{verbatim}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($f->{"isbullet"} or $f->{"width"} == 1 or $f->{"verbatim"}) 44 22 66
Condition66%4/6
$f->{"isbullet"} or $f->{"width"} == 1 or $f->{"verbatim"}
l!l&&r!l&&!r
22044
$f->{"isbullet"} or $f->{"width"} == 1
l!l&&r!l&&!r
02244
MC/DC33%1/3
$f->{"isbullet"} or $f->{"width"} == 1 or $f->{"verbatim"}
$f->{"isbullet"} $f->{"width"} == 1 $f->{"verbatim"}
Truth table50%2/4
A or B or C
A= $f->{"isbullet"}B= $f->{"width"} == 1C= $f->{"verbatim"}
ABCresult
1XX1
01X1
0011
0000
800 44 ($skipped) = ($$str_ref =~ /\G(\s*)/gc);
801 44 ▶ if ($skipped||=0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skipped ||= 0) 0 44 44
Condition50%1/2
$skipped ||= 0
l!l
044
MC/DC0%0/1
$skipped ||= 0
$skipped
Truth table50%1/2
A
A= $skipped
Aresult
11
00
802 0 $bulleted = ($skipped =~ /\n/);
803 0 $skipped=~s/\r\Z//;
804 0 $skipped = ($skipped=~tr/\r//);
805 0 push @col, ("") x $skipped;
806 0 ▶ last if $tabular && $bulleted && @col;
Branch: 1 branch
BranchTrueFalseTotal
if $tabular and $bulleted and @col 0 0 0
Condition0%0/6
$tabular and $bulleted and @col
!ll&&!rl&&r
000
$tabular and $bulleted
!ll&&!rl&&r
000
MC/DC0%0/3
$tabular and $bulleted and @col
$tabular $bulleted @col
Truth table0%0/4
A and B and C
A= $tabularB= $bulletedC= @col
ABCresult
0XX0
10X0
1100
1111
807 }
808 }
809 66 ▶ my $prev_pos = pos(${$str_ref}) // -1;
Condition100%2/2
pos ${$str_ref;} // -1
l!l
4422
MC/DC100%1/1
pos ${$str_ref;} // -1
pos ${$str_ref;}
Truth table100%2/2
A
A= pos ${$str_ref;}
Aresult
11
00
810 66 ($text,$more,$eol) = $f->{break}->($str_ref,$width,$f->{opts}{ws});
811 0 ▶ if ($text eq q{} && $more && (pos(${$str_ref})//-1) == $prev_pos) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text eq "" and $more and (pos ${$str_ref;} // -1) == $prev_pos) 0 66 66
Condition37%3/8
$text eq "" and $more and (pos ${$str_ref;} // -1) == $prev_pos
!ll&&!rl&&r
6600
$text eq "" and $more
!ll&&!rl&&r
44220
pos ${$str_ref;} // -1
l!l
00
MC/DC0%0/3
$text eq "" and $more and (pos ${$str_ref;} // -1) == $prev_pos
$text eq "" $more pos ${$str_ref;}
Truth table50%2/4
A and B and C
A= $text eq ""B= $moreC= pos ${$str_ref;}
ABCresult
0XX0
10X0
1100
1111
812 0 $text = substr(${$str_ref}, pos(${$str_ref}), 1);
813 0 pos(${$str_ref})++;
814 0 $more = pos(${$str_ref}) < length(${$str_ref});
815 }
816 66 ▶ if ($f->{opts}{ws}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f->{"opts"}{"ws"}) 0 66 66
817 0 $text =~ s{($f->{opts}{ws})}
818 0 { @caps = grep { defined $$_ } 2..$#+;
819 0 ▶ @caps = length($1) ? " " : "" unless @caps;
Branch: 2 branches
BranchTrueFalseTotal
unless @caps 0 0 0
length $1 ? : 0 0 0
820 0 join "", @caps;
821 }ge;
822 }
823 66 ▶ $text .= "\r" if $eol;
Branch: 1 branch
BranchTrueFalseTotal
if $eol 22 44 66
824 66 push @col, $text;
825 66 ▶ if ($bullet && $text =~ /\S/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bullet and $text =~ /\S/) 0 66 66
Condition33%1/3
$bullet and $text =~ /\S/
!ll&&!rl&&r
6600
MC/DC0%0/2
$bullet and $text =~ /\S/
$bullet $text =~ /\S/
Truth table33%1/3
A and B
A= $bulletB= $text =~ /\S/
ABresult
0X0
100
111
826 0 push @{$bullet->{bullets}}, ($bullet->{bullethole}) x $skipped;
827 0 ▶ push @{$bullet->{bullets}}, $bulleted ? ${$bullet->{isbullet}}
Branch: 1 branch
BranchTrueFalseTotal
$bulleted ? : 0 0 0
828 0 : $bullet->{bullethole};
829 }
830 $f->{done} = 1
831 66 ▶ if defined $f->{opts}{height}{max} && @col==$f->{opts}{height}{max};
Branch: 1 branch
BranchTrueFalseTotal
if defined $f->{"opts"}{"height"}{"max"} and @col == $f->{"opts"}{"height"}{"max"} 0 66 66
Condition66%2/3
defined $f->{"opts"}{"height"}{"max"} and @col == $f->{"opts"}{"height"}{"max"}
!ll&&!rl&&r
44220
MC/DC0%0/2
defined $f->{"opts"}{"height"}{"max"} and @col == $f->{"opts"}{"height"}{"max"}
defined $f->{"opts"}{"height"}{"max"} @col == $f->{"opts"}{"height"}{"max"}
Truth table66%2/3
A and B
A= defined $f->{"opts"}{"height"}{"max"}B= @col == $f->{"opts"}{"height"}{"max"}
ABresult
0X0
100
111
832 66 ▶ last if !$more || @col==$maxheight;
Branch: 1 branch
BranchTrueFalseTotal
if not $more or @col == $maxheight 66 0 66
Condition33%1/3
not $more or @col == $maxheight
l!l&&r!l&&!r
6600
MC/DC0%0/2
not $more or @col == $maxheight
not $more @col == $maxheight
Truth table33%1/3
not(A) or B
A= not $moreB= @col == $maxheight
ABresult
1X1
011
000
833 0 ▶ $f->{done} = 1 if $f->{line};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"line"} 0 0 0
834 0 $bulleted = 0;
835 }
836 66 ▶ @col = () if @col == 1 && $col[0] eq "";
Branch: 1 branch
BranchTrueFalseTotal
if @col == 1 and $col[0] eq "" 22 44 66
Condition66%2/3
@col == 1 and $col[0] eq ""
!ll&&!rl&&r
04422
MC/DC50%1/2
@col == 1 and $col[0] eq ""
@col == 1 $col[0] eq ""
Truth table66%2/3
A and B
A= @col == 1B= $col[0] eq ""
ABresult
0X0
100
111
837 66 ▶ $_[3] = $more && !$f->{done} if @_>3;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 3 0 66 66
Condition0%0/3
$more && !$f->{'done'}
!ll&&!rl&&r
000
MC/DC0%0/2
$more && !$f->{'done'}
$more !$f->{'done'}
Truth table0%0/3
A && not(B)
A= $moreB= !$f->{'done'}
ABresult
0X0
100
111
838 66 return \@col;
839 }
840  
841 2 my $count = 0;
842  
843 66 ▶sub balance_cols {
Subroutine balance_cols: called CC=7 SCAR=34.0
Pod undocumented
844 66 my ($group, $opts, $maxheight) = @_;
845 66 my ($first, $src) = ($group->[0], $group->[0]{src});
846 66 ▶ if (@$group<=1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$group <= 1) 66 0 66
847 66 $first->{formcol} = make_col($first,$opts,$maxheight);
848 66 return;
849 }
850 0 ▶ my $pos = pos($$src) || 0;
Condition0%0/2
pos $$src || 0
l!l
00
MC/DC0%0/1
pos $$src || 0
pos $$src
Truth table0%0/2
A
A= pos $$src
Aresult
11
00
851 0 my $minheight = 0;
852 0 while (1) {
853 0 my @cols;
854 0 pos($$src) = $pos;
855 0 my $medheight = int(($maxheight+$minheight+1)/2);
856 0 for my $f (@$group) {
857 0 $f->{done} = 0;
858 0 push @cols, make_col($f,$opts,$medheight)
859 }
860 0 ▶ if ($maxheight <= $minheight+1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($maxheight <= $minheight + 1) 0 0 0
861 0 for (0..$#cols) {
862 0 $group->[$_]{formcol} = $cols[$_];
863 }
864 0 return;
865 }
866 0 ▶ (substr($$src,pos$$src) =~ /\S/) ? $minheight : $maxheight = $medheight;
Branch: 1 branch
BranchTrueFalseTotal
substr($$src, pos $$src) =~ /\S/ ? : 0 0 0
867 }
868 }
869  
870 22 ▶sub delineate_overflows {
Subroutine delineate_overflows: called CC=12 SCAR=33.4
Pod undocumented
871 22 for my $formats (@_) {
872 # Is there a block field on the line?
873 22 ▶ next if grep { !( $_->{line}
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $_->{"line"} || $_->{"literal"} || $_->{"notlastoverflow"};} @$formats 0 22 22
874 || $_->{literal}
875 || $_->{notlastoverflow}
876 )
877 66 ▶ } @$formats;
Condition50%3/6
$_->{'line'} || $_->{'literal'} || $_->{'notlastoverflow'}
l!l&&r!l&&!r
6600
$_->{"line"} or $_->{"literal"}
l!l&&r!l&&!r
22440
MC/DC0%0/3
$_->{'line'} || $_->{'literal'} || $_->{'notlastoverflow'}
$_->{"line"} $_->{"literal"} $_->{'notlastoverflow'}
Truth table50%2/4
A or B || C
A= $_->{"line"}B= $_->{"literal"}C= $_->{'notlastoverflow'}
ABCresult
1XX1
01X1
0011
0000
878 22 for (@$formats) {
879 66 ▶ next unless $_->{overflow};
Branch: 1 branch
BranchTrueFalseTotal
unless $_->{"overflow"} 66 0 66
880 0 ▶ if ($_->{notlastoverflow}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"notlastoverflow"}) 0 0 0
881 0 $_->{line} = 1;
882 }
883 }
884 }
885 22 for my $formats (@_) {
886 22 for (@$formats) {
887 66 ▶ next if !$_->{overflow} || $_->{notlastoverflow};
Branch: 1 branch
BranchTrueFalseTotal
if not $_->{"overflow"} or $_->{"notlastoverflow"} 66 0 66
Condition33%1/3
not $_->{"overflow"} or $_->{"notlastoverflow"}
l!l&&r!l&&!r
6600
MC/DC0%0/2
not $_->{"overflow"} or $_->{"notlastoverflow"}
not $_->{"overflow"} $_->{"notlastoverflow"}
Truth table33%1/3
not(A) or B
A= not $_->{"overflow"}B= $_->{"notlastoverflow"}
ABresult
1X1
011
000
888 0 $_->{opts}{height}{max} = $unlimited;
889 0 $_->{opts}{height}{minimal} = 0;
890 }
891 }
892 }
893  
894 22 ▶sub resolve_overflows {
Subroutine resolve_overflows: called CC=12 SCAR=48.0
Pod undocumented
895 22 my ($formatters,$prevformatters) = @_;
896 22 FORMATTER: for my $fld (@$formatters) {
897 66 ▶ next unless $fld->{overflow};
Branch: 1 branch
BranchTrueFalseTotal
unless $fld->{"overflow"} 66 0 66
898 0 my $left = $fld->{pos};
899 0 my $right = $left + $fld->{width} - 1;
900 0 my $overflowed;
901 0 for my $prev (@$prevformatters) {
902 0 ▶ next if $prev->{literal};
Branch: 1 branch
BranchTrueFalseTotal
if $prev->{"literal"} 0 0 0
903 0 my $prevleft = $prev->{pos};
904 0 my $prevright = $prevleft + $prev->{width} - 1;
905 0 ▶ if ($right >= $prevleft && $left <= $prevright) { # overlap
Branch: 1 branch
BranchTrueFalseTotal
if ($right >= $prevleft and $left <= $prevright) 0 0 0
Condition0%0/3
$right >= $prevleft and $left <= $prevright
!ll&&!rl&&r
000
MC/DC0%0/2
$right >= $prevleft and $left <= $prevright
$right >= $prevleft $left <= $prevright
Truth table0%0/3
A and B
A= $right >= $prevleftB= $left <= $prevright
ABresult
0X0
100
111
906 0 ▶ if ($overflowed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($overflowed) 0 0 0
907 $prev->{notlastoverflow} = 1
908 0 ▶ if $prev->{overflow} && $prev->{src} == $fld->{src};
Branch: 1 branch
BranchTrueFalseTotal
if $prev->{"overflow"} and $prev->{"src"} == $fld->{"src"} 0 0 0
Condition0%0/3
$prev->{"overflow"} and $prev->{"src"} == $fld->{"src"}
!ll&&!rl&&r
000
MC/DC0%0/2
$prev->{"overflow"} and $prev->{"src"} == $fld->{"src"}
$prev->{"overflow"} $prev->{"src"} == $fld->{"src"}
Truth table0%0/3
A and B
A= $prev->{"overflow"}B= $prev->{"src"} == $fld->{"src"}
ABresult
0X0
100
111
909 0 next;
910 }
911 0 my %newfld = ( %$prev, opts=>{}, overflow=>1 );
912 0 my @keep = qw( width pos complete done line );
913 0 @newfld{@keep} = @{$fld}{@keep};
914 0 update %{$newfld{opts}}, %{$fld->{opts}};
915 0 $newfld{opts}{height} = {min=>0, max=>undef, minimal=>1};
916 0 $fld = \%newfld;
917 0 ▶ $prev->{notlastoverflow} = 1 if $prev->{overflow};
Branch: 1 branch
BranchTrueFalseTotal
if $prev->{"overflow"} 0 0 0
918 0 $overflowed = 1;
919 }
920 }
921 0 ▶ croak "Useless overflow field (no field above it)"
Branch: 1 branch
BranchTrueFalseTotal
unless $overflowed 0 0 0
922 unless $overflowed;
923 }
924 }
925  
926 22 ▶sub make_cols($$\@\%$) {
Subroutine make_cols: called CC=89 SCAR=84.4
Pod undocumented
927 22 my ($formatters,$prevformatters,$parts, $opts, $maxheight) = @_;
928 22 my (@bullets, @max, @min);
929 22 for my $f (@$formatters) {
930 0 ▶ if ($f->{isbullet}) { push @bullets, $f }
Branch: 2 branches
BranchTrueFalseTotal
if ($f->{'isbullet'}) { } 0 66 66
elsif ($f->{'opts'}{'height'}{'minimal'}) { } 0 66 66
931 0 elsif ($f->{opts}{height}{minimal}) { push @min, $f }
932 66 else { push @max, $f }
933 }
934 22 my @maxgroups = layout_groups(@max);
935 22 my @mingroups = layout_groups(@min);
936 22 ▶ my $has_nonminimal = grep {!$_->{literal} && !$_->{line}} @max;
Condition66%2/3
$_->{'literal'} || $_->{'line'}
l!l&&r!l&&!r
44220
MC/DC0%0/2
$_->{'literal'} || $_->{'line'}
$_->{'literal'} $_->{'line'}
Truth table66%2/3
A || B
A= $_->{'literal'}B= $_->{'line'}
ABresult
1X1
011
000
937 22 ▶ if ($opts->{layout} eq 'balanced') { # balanced column-by-column
Branch: 3 branches
BranchTrueFalseTotal
if ($opts->{'layout'} eq 'balanced') { } 22 0 22
elsif ($opts->{'layout'} eq 'down') { } 0 0 0
elsif ($opts->{'layout'} eq 'across') { } 0 0 0
938 22 for my $g (@maxgroups) {
939 66 balance_cols($g,$opts, $maxheight);
940 }
941 66 ▶ $maxheight = map 0+@{$_->{formcol}||[]}, @$formatters
Condition50%1/2
$_->{'formcol'} || []
l!l
660
MC/DC0%0/1
$_->{'formcol'} || []
$_->{'formcol'}
Truth table50%1/2
A
A= $_->{'formcol'}
Aresult
11
00
942 22 ▶ if grep {!$_->{literal} && !$_->{opts}{height}{minimal}} @$formatters;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $_->{"literal"} || $_->{"opts"}{"height"}{"minimal"};} @$formatters 22 0 22
Condition66%2/3
$_->{'literal'} || $_->{'opts'}{'height'}{'minimal'}
l!l&&r!l&&!r
44022
MC/DC50%1/2
$_->{'literal'} || $_->{'opts'}{'height'}{'minimal'}
$_->{'literal'} $_->{'opts'}{'height'}{'minimal'}
Truth table66%2/3
A || B
A= $_->{'literal'}B= $_->{'opts'}{'height'}{'minimal'}
ABresult
1X1
011
000
943 22 for my $g (@mingroups) {
944 0 balance_cols($g, $opts, $maxheight);
945 }
946 22 for my $f (@$formatters) {
947 66 ▶ push @$parts, $f->{formcol}||$f->{bullets}||[];
Condition40%2/5
$f->{'formcol'} || $f->{'bullets'} || []
l!l
660
$f->{"formcol"} or $f->{"bullets"}
l!l&&r!l&&!r
6600
MC/DC0%0/2
$f->{'formcol'} || $f->{'bullets'} || []
$f->{"formcol"} $f->{"bullets"}
Truth table33%1/3
A or B
A= $f->{"formcol"}B= $f->{"bullets"}
ABresult
1X1
011
000
948 }
949 }
950 elsif ($opts->{layout} eq 'down') { # column-by-column
951 0 for my $col (0..$#$formatters) {
952 0 my $f = $formatters->[$col];
953 0 ▶ next if $f->{isbullet} || $f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/3
$f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
$f->{"isbullet"} $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/3
A or B
A= $f->{"isbullet"}B= $f->{"opts"}{"height"}{"minimal"}
ABresult
1X1
011
000
954 0 $parts->[$col] = make_col($f,$opts, $maxheight);
955 }
956 $maxheight = min $maxheight,
957 0 ▶ max map { defined() ? scalar @$_ : 0 } @$parts
Branch: 2 branches
BranchTrueFalseTotal
if $has_nonminimal 0 0 0
defined $_ ? : 0 0 0
958 if $has_nonminimal;
959 0 for my $col (0..$#$formatters) {
960 0 my $f = $formatters->[$col];
961 0 ▶ next if $f->{isbullet} || !$f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/3
$f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"}
$f->{"isbullet"} not $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/3
A or not(B)
A= $f->{"isbullet"}B= not $f->{"opts"}{"height"}{"minimal"}
ABresult
1X1
011
000
962 0 $parts->[$col] = make_col($f,$opts, $maxheight);
963 }
964 0 for my $col (0..$#$formatters) {
965 0 my $f = $formatters->[$col];
966 0 ▶ next unless $f->{isbullet};
Branch: 1 branch
BranchTrueFalseTotal
unless $f->{"isbullet"} 0 0 0
967 0 ▶ $parts->[$col] = $f->{bullets}||[];
Condition0%0/2
$f->{'bullets'} || []
l!l
00
MC/DC0%0/1
$f->{'bullets'} || []
$f->{'bullets'}
Truth table0%0/2
A
A= $f->{'bullets'}
Aresult
11
00
968 }
969 }
970 elsif ($opts->{layout} eq 'across') { # across row-by-row
971 0 my %incomplete = (first=>1);
972 0 ▶ for (my $row=0;$row<$maxheight && grep {$_} values %incomplete;$row++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row < $maxheight and grep {$_;} values %incomplete) 0 0 0
Condition0%0/3
$row < $maxheight and grep {$_;} values %incomplete
!ll&&!rl&&r
000
MC/DC0%0/2
$row < $maxheight and grep {$_;} values %incomplete
$row < $maxheight grep {$_;} values %incomplete
Truth table0%0/3
A and B
A= $row < $maxheightB= grep {$_;} values %incomplete
ABresult
0X0
100
111
973 0 %incomplete = ();
974 0 for my $col (0..$#$formatters) {
975 0 ▶ $parts->[$col] ||= [];
Condition0%0/2
$parts->[$col] ||= []
l!l
00
MC/DC0%0/1
$parts->[$col] ||= []
$parts->[$col]
Truth table0%0/2
A
A= $parts->[$col]
Aresult
11
00
976 }
977 0 for my $col (0..$#$formatters) {
978 0 my $f = $formatters->[$col];
979 0 ▶ next if $f->{isbullet} || $f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/3
$f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
$f->{"isbullet"} $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/3
A or B
A= $f->{"isbullet"}B= $f->{"opts"}{"height"}{"minimal"}
ABresult
1X1
011
000
980 0 ▶ next if $f->{line} && $row>0 || $f->{done};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"line"} and $row > 0 or $f->{"done"} 0 0 0
Condition0%0/6
$f->{"line"} and $row > 0 or $f->{"done"}
l!l&&r!l&&!r
000
$f->{"line"} and $row > 0
!ll&&!rl&&r
000
MC/DC0%0/3
$f->{"line"} and $row > 0 or $f->{"done"}
$f->{"line"} $row > 0 $f->{"done"}
Truth table0%0/5
A and B or C
A= $f->{"line"}B= $row > 0C= $f->{"done"}
ABCresult
11X1
0X11
1011
0X00
1000
981 0 my ($str_ref, $width) = @{$f}{qw(src width)};
982 0 ▶ $$str_ref =~ /\G\s+/gc unless $f->{verbatim};
Branch: 1 branch
BranchTrueFalseTotal
unless $f->{"verbatim"} 0 0 0
983 ($parts->[$col][$row], my $more) =
984 0 $f->{break}->($str_ref,$width,$f->{opts}{ws});
985 0 ▶ $parts->[$col][$row] =~ s/$f->{opts}{ws}/ /g if $f->{opts}{ws};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"opts"}{"ws"} 0 0 0
986 $f->{done} = 1 if !$f->{literal}
987 0 ▶ && $row+1 >= ($f->{opts}{height}{max}||$maxheight);
Branch: 1 branch
BranchTrueFalseTotal
if not $f->{"literal"} and $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight) 0 0 0
Condition0%0/6
not $f->{"literal"} and $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
!ll&&!rl&&r
000
$f->{'opts'}{'height'}{'max'} || $maxheight
l!l&&r!l&&!r
000
MC/DC0%0/2
not $f->{"literal"} and $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
not $f->{"literal"} $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
MC/DC0%0/2
$f->{'opts'}{'height'}{'max'} || $maxheight
$f->{'opts'}{'height'}{'max'} $maxheight
Truth table0%0/3
not(A) and B
A= not $f->{"literal"}B= $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
ABresult
0X0
100
111
Truth table0%0/3
A || B
A= $f->{'opts'}{'height'}{'max'}B= $maxheight
ABresult
1X1
011
000
988 $incomplete{$str_ref} = $more
989 0 ▶ unless $f->{literal} || $f->{line} || $f->{done};
Branch: 1 branch
BranchTrueFalseTotal
unless $f->{"literal"} or $f->{"line"} or $f->{"done"} 0 0 0
Condition0%0/6
$f->{"literal"} or $f->{"line"} or $f->{"done"}
l!l&&r!l&&!r
000
$f->{"literal"} or $f->{"line"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$f->{"literal"} or $f->{"line"} or $f->{"done"}
$f->{"literal"} $f->{"line"} $f->{"done"}
Truth table0%0/4
A or B or C
A= $f->{"literal"}B= $f->{"line"}C= $f->{"done"}
ABCresult
1XX1
01X1
0011
0000
990 }
991 0 for my $col (0..$#$formatters) {
992 0 my $f = $formatters->[$col];
993 0 ▶ next if $f->{isbullet} || !$f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/3
$f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"}
$f->{"isbullet"} not $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/3
A or not(B)
A= $f->{"isbullet"}B= not $f->{"opts"}{"height"}{"minimal"}
ABresult
1X1
011
000
994 0 ▶ next if $f->{line} && $row>0 || $f->{done};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"line"} and $row > 0 or $f->{"done"} 0 0 0
Condition0%0/6
$f->{"line"} and $row > 0 or $f->{"done"}
l!l&&r!l&&!r
000
$f->{"line"} and $row > 0
!ll&&!rl&&r
000
MC/DC0%0/3
$f->{"line"} and $row > 0 or $f->{"done"}
$f->{"line"} $row > 0 $f->{"done"}
Truth table0%0/5
A and B or C
A= $f->{"line"}B= $row > 0C= $f->{"done"}
ABCresult
11X1
0X11
1011
0X00
1000
995 0 my ($str_ref, $width) = @{$f}{qw(src width)};
996 0 ▶ $$str_ref =~ /\G\s+/gc unless $f->{verbatim};
Branch: 1 branch
BranchTrueFalseTotal
unless $f->{"verbatim"} 0 0 0
997 ($parts->[$col][$row], my $more) =
998 0 $f->{break}->($str_ref,$width,$f->{opts}{ws});
999 0 ▶ $parts->[$col][$row] =~ s/$f->{opts}{ws}/ /g if $f->{opts}{ws};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"opts"}{"ws"} 0 0 0
1000 $f->{done} = 1 if !$f->{literal}
1001 0 ▶ && $row+1 >= ($f->{opts}{height}{max}||$maxheight);
Branch: 1 branch
BranchTrueFalseTotal
if not $f->{"literal"} and $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight) 0 0 0
Condition0%0/6
not $f->{"literal"} and $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
!ll&&!rl&&r
000
$f->{'opts'}{'height'}{'max'} || $maxheight
l!l&&r!l&&!r
000
MC/DC0%0/2
not $f->{"literal"} and $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
not $f->{"literal"} $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
MC/DC0%0/2
$f->{'opts'}{'height'}{'max'} || $maxheight
$f->{'opts'}{'height'}{'max'} $maxheight
Truth table0%0/3
not(A) and B
A= not $f->{"literal"}B= $row + 1 >= ($f->{"opts"}{"height"}{"max"} || $maxheight)
ABresult
0X0
100
111
Truth table0%0/3
A || B
A= $f->{'opts'}{'height'}{'max'}B= $maxheight
ABresult
1X1
011
000
1002 $incomplete{$str_ref} = $more
1003 0 ▶ unless $has_nonminimal || $f->{done};
Branch: 1 branch
BranchTrueFalseTotal
unless $has_nonminimal or $f->{"done"} 0 0 0
Condition0%0/3
$has_nonminimal or $f->{"done"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$has_nonminimal or $f->{"done"}
$has_nonminimal $f->{"done"}
Truth table0%0/3
A or B
A= $has_nonminimalB= $f->{"done"}
ABresult
1X1
011
000
1004 }
1005 0 for my $col (0..$#$formatters) {
1006 0 my $f = $formatters->[$col];
1007 0 ▶ next unless $f->{isbullet};
Branch: 1 branch
BranchTrueFalseTotal
unless $f->{"isbullet"} 0 0 0
1008 0 $parts->[$col][$row] = shift @{$f->{bullets}};
1009 }
1010 }
1011 }
1012 else { # tabular layout: down to the first \n, then across, then fill
1013 0 my $finished = 0;
1014 0 for my $col (0..$#$formatters) { $parts->[$col] = []; }
1015 0 ▶ while (!$finished) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($finished) 0 0 0
1016 0 $finished = 1;
1017 0 for my $col (0..$#$formatters) {
1018 0 my $tabular_more = 1;
1019 0 my $f = $formatters->[$col];
1020 0 ▶ next if $f->{isbullet} || $f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/3
$f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
$f->{"isbullet"} $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/3
A or B
A= $f->{"isbullet"}B= $f->{"opts"}{"height"}{"minimal"}
ABresult
1X1
011
000
1021 0 push @{$parts->[$col]},
1022 0 @{make_col($f,$opts, $maxheight, $tabular_more)};
1023 0 ▶ $finished &&= !$tabular_more;
Condition0%0/3
$finished &&= !$tabular_more
!ll&&!rl&&r
000
MC/DC0%0/2
$finished &&= !$tabular_more
$finished !$tabular_more
Truth table0%0/3
A &&= not(B)
A= $finishedB= !$tabular_more
ABresult
0X0
100
111
1024 }
1025 my $minimaxheight = min $maxheight,
1026 0 ▶ max map { defined() ? scalar @$_ : 0 } @$parts
Branch: 2 branches
BranchTrueFalseTotal
if $has_nonminimal 0 0 0
defined $_ ? : 0 0 0
1027 if $has_nonminimal;
1028 0 for my $col (0..$#$formatters) {
1029 0 my $tabular = 1;
1030 0 my $f = $formatters->[$col];
1031 0 ▶ next if $f->{isbullet} || !$f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/3
$f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f->{"isbullet"} or not $f->{"opts"}{"height"}{"minimal"}
$f->{"isbullet"} not $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/3
A or not(B)
A= $f->{"isbullet"}B= not $f->{"opts"}{"height"}{"minimal"}
ABresult
1X1
011
000
1032 0 push @{$parts->[$col]},
1033 0 @{make_col($f,$opts, $maxheight, $tabular)};
1034 }
1035 0 for my $col (0..$#$formatters-1) {
1036 0 my $f = $formatters->[$col];
1037 0 ▶ if ($f->{isbullet}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($f->{'isbullet'}) { } 0 0 0
elsif ($f->{'literal'}) { } 0 0 0
1038 0 ▶ push @{$parts->[$col]}, @{$f->{bullets}||[]};
Condition0%0/2
$f->{'bullets'} || []
l!l
00
MC/DC0%0/1
$f->{'bullets'} || []
$f->{'bullets'}
Truth table0%0/2
A
A= $f->{'bullets'}
Aresult
11
00
1039 0 push @{$parts->[$col]},
1040 0 ($f->{bullethole})x($minimaxheight-@{$parts->[$col]});
1041 }
1042 elsif ($f->{literal}) {
1043 0 push @{$parts->[$col]},
1044 0 (${$f->{src}})x($minimaxheight-@{$parts->[$col]});
1045 }
1046 else {
1047 0 push @{$parts->[$col]},
1048 0 ("")x($minimaxheight-@{$parts->[$col]});
1049 }
1050 }
1051 0 ▶ $maxheight -= $minimaxheight||0;
Condition0%0/2
$minimaxheight || 0
l!l
00
MC/DC0%0/1
$minimaxheight || 0
$minimaxheight
Truth table0%0/2
A
A= $minimaxheight
Aresult
11
00
1052 }
1053 }
1054 22 for my $g (@maxgroups, @mingroups) {
1055 66 my $text = $g->[-1]{src};
1056 66 ▶ next if substr($$text,pos($$text)||0) =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if substr($$text, pos $$text || 0) =~ /\S/ 0 66 66
Condition100%2/2
pos $$text || 0
l!l
2244
MC/DC100%1/1
pos $$text || 0
pos $$text
Truth table100%2/2
A
A= pos $$text
Aresult
11
00
1057 66 for (1..@$g) {
1058 66 ▶ next unless @{$parts->[$g->[-$_]{index}]};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$$parts[$$g[-$_]{"index"}];} 22 44 66
1059 44 $g->[-$_]{final} = 1;
1060 44 last;
1061 }
1062 }
1063 22 for my $i (1..@$parts) {
1064 66 $formatters->[-$i]{complete} = 0
1065 }
1066 22 ▶ for my $f (grep {!($_->{literal}||$_->{line})} @$formatters) {
Condition66%2/3
$_->{'literal'} || $_->{'line'}
l!l&&r!l&&!r
44220
MC/DC0%0/2
$_->{'literal'} || $_->{'line'}
$_->{'literal'} $_->{'line'}
Truth table66%2/3
A || B
A= $_->{'literal'}B= $_->{'line'}
ABresult
1X1
011
000
1067 0 ▶ next if $f->{done} || $f->{isbullet} || $f->{opts}{height}{minimal};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"done"} or $f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"} 0 0 0
Condition0%0/6
$f->{"done"} or $f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
l!l&&r!l&&!r
000
$f->{"done"} or $f->{"isbullet"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$f->{"done"} or $f->{"isbullet"} or $f->{"opts"}{"height"}{"minimal"}
$f->{"done"} $f->{"isbullet"} $f->{"opts"}{"height"}{"minimal"}
Truth table0%0/4
A or B or C
A= $f->{"done"}B= $f->{"isbullet"}C= $f->{"opts"}{"height"}{"minimal"}
ABCresult
1XX1
01X1
0011
0000
1068 0 ▶ return 1 if substr(${$f->{src}},pos(${$f->{src}})||0) =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if substr(${$f->{"src"};}, pos ${$$f{"src"};} || 0) =~ /\S/ 0 0 0
Condition0%0/2
pos ${$$f{'src'};} || 0
l!l
00
MC/DC0%0/1
pos ${$$f{'src'};} || 0
pos ${$$f{'src'};}
Truth table0%0/2
A
A= pos ${$$f{'src'};}
Aresult
11
00
1069 }
1070 22 return 0;
1071 }
1072  
1073 0 ▶sub make_underline {
Subroutine make_underline: not called CC=4 SCAR=30.0
Pod undocumented
1074 0 my ($under, $prevline, $nextline) = @_;
1075 0 $under =~ s/(\n*)\z//;
1076 0 my $trail = "$1"|"\n";
1077 0 for my $l ($nextline, $prevline) {
1078 0 ▶ $l = join "", map {$_->{literal} ? ${$_->{src}} : '*'x$_->{width} } @$l;
Branch: 1 branch
BranchTrueFalseTotal
$_->{'literal'} ? : 0 0 0
1079 0 ▶ $l =~ s{(.)}{$1 =~ /\s/ ? "\0" : "\1"}ges;
Branch: 1 branch
BranchTrueFalseTotal
$1 =~ /\s/ ? : 0 0 0
1080 }
1081 0 $nextline |= $prevline;
1082 0 $nextline =~ s{\0}{ }g;
1083 0 $nextline =~ s{(\cA+)}{my $len=length($1); substr($under x $len,0,$len)}ge;
1084 0 $nextline .= $trail;
1085 0 return [{ %std_literal, width => length($nextline), src => \$nextline }];
1086 }
1087  
1088 88 ▶sub linecount($) {
Subroutine linecount: called CC=3 SCAR=12.0
Pod undocumented
1089 88 ▶ return tr/\n// + (/[^\n]\z/?1:0) for @_;
Branch: 1 branch
BranchTrueFalseTotal
/[^\n]\z/ ? : 0 88 88
1090 }
1091  
1092 2 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
1093  
1094 2 ▶sub form is export(:MANDATORY) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=2 SCAR=6.9
Subroutine form: called CC=46 SCAR=50.0
Pod undocumented
1095 22 ▶ croak "Useless call to &form in void context" unless defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 0 22 22
1096  
1097 # Handle formatting calls...
1098 22 my ($package, $file, $line) = caller;
1099 22 ▶ my $caller_opts = $caller_opts{$package,$file} ||= {};
Condition50%1/2
$caller_opts{join $;, $package, $file} ||= {}
l!l
220
MC/DC0%0/1
$caller_opts{join $;, $package, $file} ||= {}
$caller_opts{join $;, $package, $file}
Truth table50%1/2
A
A= $caller_opts{join $;, $package, $file}
Aresult
11
00
1100 22 ▶ if (keys %$caller_opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$caller_opts) 22 0 22
1101 0 ▶ $line = first { $_ < $line } sort {$b<=>$a} keys %$caller_opts;
Subroutine __ANON__: called CC=1 SCAR=0.4
1102 22 ▶ $caller_opts = $caller_opts->{$line} || {}
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 22 0 22
Condition50%1/2
$caller_opts->{$line} || {}
l!l
220
MC/DC0%0/1
$caller_opts->{$line} || {}
$caller_opts->{$line}
Truth table50%1/2
A
A= $caller_opts->{$line}
Aresult
11
00
1103 if defined $line;
1104 }
1105 22 my %opts = (%def_opts, %$caller_opts);
1106 22 my $fldcnt = 0;
1107 22 my @section = {opts=>{%opts}, text=>[]};
1108 22 my $formats = \@_;
1109 22 my $first = 1;
1110 22 my %argcache;
1111 22 my ($prevformat,$currformat,@allformats);
1112 22 ▶ while (@$formats) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$formats) 22 22 44
1113 22 my $format = shift @$formats;
1114 22 ▶ if (ref $format eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $format eq "HASH") 0 22 22
1115 0 update %opts, %$format;
1116 0 ▶ $opts{page}{number} = undef unless defined $format->{page}{number};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $format->{"page"}{"number"} 0 0 0
1117 0 push @section, {opts=>{%opts}};
1118 0 redo;
1119 }
1120 22 ▶ if ($first) { # Change format lists if data first or last
Branch: 1 branch
BranchTrueFalseTotal
if ($first) 22 0 22
1121 22 ▶ if ($opts{interleave}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"interleave"}) 0 22 22
1122 0 $formats = [$format =~ /.*(?:\n|\z)/g];
1123 0 $format = shift @$formats;
1124 }
1125 22 $first = 0;
1126 }
1127 22 $format =~ s/\n?\z/\n/;
1128 22 $prevformat = $currformat;
1129 22 $currformat = segment($format, @_, %opts, $fldcnt, %argcache);
1130 22 resolve_overflows($currformat, $prevformat);
1131 22 ▶ if (defined $opts{under}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"under"}) 0 22 22
1132 0 push @{$section[-1]{formatters}},
1133 0 make_underline($opts{under}, $prevformat, $currformat);
1134 0 $opts{under} = undef;
1135 }
1136 22 push @{$section[-1]{formatters}}, $currformat;
1137 22 push @allformats, $currformat;
1138 }
1139 22 ▶ croak scalar(@_), " too many data values after last format" if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 22 22
1140 22 delineate_overflows(@allformats);
1141  
1142 22 my $text = "";
1143 22 my $pagetype = 'first';
1144 22 my $pagenum = 1;
1145 22 for my $section (@section) {
1146 22 ▶ next unless $section->{formatters};
Branch: 1 branch
BranchTrueFalseTotal
unless $section->{"formatters"} 0 22 22
1147 22 my $sect_opts = $section->{opts};
1148 22 my $page = $sect_opts->{page};
1149 22 ▶ $page->{number} = $pagenum unless defined $page->{number};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $page->{"number"} 1 21 22
1150 22 my $pagelen = $page->{length};
1151 22 while (1) {
1152 22 ▶ my $parity = $page->{number}%2 ? 'odd' : 'even';
Branch: 1 branch
BranchTrueFalseTotal
$page->{'number'} % 2 ? : 11 11 22
1153 my $header =
1154 $page->{header}{$pagetype} ? $page->{header}{$pagetype}($sect_opts)
1155 : $page->{header}{$parity} ? $page->{header}{$parity}($sect_opts)
1156 22 ▶ : $page->{header}{other} ? $page->{header}{other}($sect_opts)
Branch: 3 branches
BranchTrueFalseTotal
$page->{'header'}{$pagetype} ? : 22 0 22
$page->{'header'}{$parity} ? : 0 0 0
$page->{'header'}{'other'} ? : 0 0 0
1157 : "";
1158 my $footer =
1159 $page->{footer}{$pagetype} ? $page->{footer}{$pagetype}($sect_opts)
1160 : $page->{footer}{$parity} ? $page->{footer}{$parity}($sect_opts)
1161 22 ▶ : $page->{footer}{other} ? $page->{footer}{other}($sect_opts)
Branch: 3 branches
BranchTrueFalseTotal
$page->{'footer'}{$pagetype} ? : 22 0 22
$page->{'footer'}{$parity} ? : 0 0 0
$page->{'footer'}{'other'} ? : 0 0 0
1162 : "";
1163 my $feed =
1164 $page->{feed}{$pagetype} ? $page->{feed}{$pagetype}($sect_opts)
1165 : $page->{feed}{$parity} ? $page->{feed}{$parity}($sect_opts)
1166 22 ▶ : $page->{feed}{other} ? $page->{feed}{other}($sect_opts)
Branch: 3 branches
BranchTrueFalseTotal
$page->{'feed'}{$pagetype} ? : 22 0 22
$page->{'feed'}{$parity} ? : 0 0 0
$page->{'feed'}{'other'} ? : 0 0 0
1167 : "";
1168 22 ▶ length and s/\n?\z/\n/ for $header, $footer; # NOT for $feed
Branch: 1 branch
BranchTrueFalseTotal
length $_ and s/\n?\z/\n/ 0 44 44
1169 my $bodyfn = $page->{body}{$pagetype}
1170 || $page->{body}{$parity}
1171 || $page->{body}{other}
1172 22 ▶ || \&std_body;
Condition37%3/8
$page->{'body'}{$pagetype} || $page->{'body'}{$parity} || $page->{'body'}{'other'} || \&std_body
l!l
220
$page->{"body"}{$pagetype} or $page->{"body"}{$parity} or $page->{"body"}{"other"}
l!l&&r!l&&!r
0220
$page->{"body"}{$pagetype} or $page->{"body"}{$parity}
l!l&&r!l&&!r
0022
MC/DC0%0/3
$page->{'body'}{$pagetype} || $page->{'body'}{$parity} || $page->{'body'}{'other'} || \&std_body
$page->{"body"}{$pagetype} $page->{"body"}{$parity} $page->{"body"}{"other"}
Truth table25%1/4
A or B or C
A= $page->{"body"}{$pagetype}B= $page->{"body"}{$parity}C= $page->{"body"}{"other"}
ABCresult
1XX1
01X1
0011
0000
1173 22 my $bodylen = max 1, $pagelen - linecount($header) - linecount($footer);
1174 22 my ($pagetext, $more) = make_page($section, $sect_opts, $bodylen);
1175 22 ▶ if (!$more && $section == $section[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $more and $section == $section[-1]) 22 0 22
Condition33%1/3
not $more and $section == $section[-1]
!ll&&!rl&&r
0022
MC/DC0%0/2
not $more and $section == $section[-1]
not $more $section == $section[-1]
Truth table33%1/3
not(A) and B
A= not $moreB= $section == $section[-1]
ABresult
0X0
100
111
1176 my $lastheader =
1177 22 ▶ $page->{header}{last} ? $page->{header}{last}($sect_opts)
Branch: 1 branch
BranchTrueFalseTotal
$page->{'header'}{'last'} ? : 0 22 22
1178 : $header;
1179 my $lastfooter =
1180 22 ▶ $page->{footer}{last} ? $page->{footer}{last}($sect_opts)
Branch: 1 branch
BranchTrueFalseTotal
$page->{'footer'}{'last'} ? : 0 22 22
1181 : $footer;
1182 22 ▶ length and s/\n?\z/\n/ for $lastheader, $lastfooter;
Branch: 1 branch
BranchTrueFalseTotal
length $_ and s/\n?\z/\n/ 0 44 44
1183 22 my $lastlen = max 1, $pagelen-linecount($lastheader)-linecount($lastfooter);
1184 22 ▶ if (@$pagetext <= $lastlen) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$pagetext <= $lastlen) 22 0 22
1185 22 $pagetype = 'last';
1186 22 ($header, $footer, $bodylen)
1187 = ($lastheader, $lastfooter, $lastlen);
1188 $feed = $page->{feed}{last}($sect_opts)
1189 22 ▶ if $page->{feed}{last};
Branch: 1 branch
BranchTrueFalseTotal
if $page->{"feed"}{"last"} 0 22 22
1190 $bodyfn = $page->{body}{last}
1191 22 ▶ if $page->{body}{last};
Branch: 1 branch
BranchTrueFalseTotal
if $page->{"body"}{"last"} 0 22 22
1192 }
1193 }
1194 22 ▶ my $fill = $pagelen < $unlimited ? [("\n") x max(0,$bodylen-@$pagetext)]
Branch: 1 branch
BranchTrueFalseTotal
$pagelen < $unlimited ? : 0 22 22
1195 : [];
1196  
1197 22 my $body = $bodyfn->($pagetext, $fill, \%opts);
1198  
1199 22 $text .= $header . $body . $footer . $feed;
1200 22 $page->{number}++;
1201  
1202 # Handle special case of empty last page...
1203 22 ▶ last unless $more || $section == $section[-1] && $pagetype ne 'last';
Branch: 1 branch
BranchTrueFalseTotal
unless $more or $section == $section[-1] and $pagetype ne "last" 22 0 22
Condition33%2/6
$more or $section == $section[-1] and $pagetype ne "last"
l!l&&r!l&&!r
0022
$section == $section[-1] and $pagetype ne "last"
!ll&&!rl&&r
0220
MC/DC0%0/3
$more or $section == $section[-1] and $pagetype ne "last"
$more $section == $section[-1] $pagetype ne "last"
Truth table25%1/4
A or B and C
A= $moreB= $section == $section[-1]C= $pagetype ne "last"
ABCresult
1XX1
0111
00X0
0100
1204 0 ▶ $pagetype = $page->{number}%2 ? 'odd' : 'even';
Branch: 1 branch
BranchTrueFalseTotal
$page->{'number'} % 2 ? : 0 0 0
1205 }
1206 22 $pagenum = $page->{number};
1207 }
1208  
1209 22 ▶ $text =~ s/[^\S\n]+\n/\n/g unless $opts{untrimmed};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"untrimmed"} 22 0 22
1210 22 return $text;
1211 }
1212  
1213 22 ▶sub make_page {
Subroutine make_page: called CC=12 SCAR=25.0
Pod undocumented
1214 22 my ($section, $sect_opts, $bodylen) = @_;
1215 22 my (@text, $more);
1216 22 my ($prevformatters, $formatters);
1217 22 ▶ while (@text < $bodylen && @{$section->{formatters}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@text < $bodylen and @{$section->{"formatters"};}) 22 22 44
Condition66%2/3
@text < $bodylen and @{$section->{"formatters"};}
!ll&&!rl&&r
02222
MC/DC50%1/2
@text < $bodylen and @{$section->{"formatters"};}
@text < $bodylen @{$section->{"formatters"};}
Truth table66%2/3
A and B
A= @text < $bodylenB= @{$section->{"formatters"};}
ABresult
0X0
100
111
1218 22 $prevformatters = $formatters;
1219 22 $formatters = $section->{formatters}[0];
1220 22 $more = make_cols($formatters,$prevformatters,my @parts, %$sect_opts, $bodylen-@text);
1221 22 ▶ shift @{$section->{formatters}} unless $more;
Branch: 1 branch
BranchTrueFalseTotal
unless $more 22 0 22
1222 22 my $maxheight = 0;
1223 22 my $maxwidth = 0;
1224 22 for my $col (0..$#parts) {
1225 66 local $_ = $parts[$col];
1226 66 ▶ pop @$_ while @$_ && ! length($_->[-1]);
Branch: 1 branch
BranchTrueFalseTotal
@$_ and not length $_->[-1] and do { pop @$_ } 0 66 66
Condition66%2/3
@$_ and not length $_->[-1]
!ll&&!rl&&r
22440
MC/DC0%0/2
@$_ and not length $_->[-1]
@$_ not length $_->[-1]
Truth table66%2/3
A and not(B)
A= @$_B= not length $_->[-1]
ABresult
0X0
100
111
1227 66 ▶ $maxheight = max($maxheight, scalar(@$_), $formatters->[$col]{opts}{height}{min}||0);
Condition50%1/2
$formatters->[$col]{'opts'}{'height'}{'min'} || 0
l!l
066
MC/DC0%0/1
$formatters->[$col]{'opts'}{'height'}{'min'} || 0
$formatters->[$col]{'opts'}{'height'}{'min'}
Truth table50%1/2
A
A= $formatters->[$col]{'opts'}{'height'}{'min'}
Aresult
11
00
1228 # $formatters->[$col]{pos} = $maxwidth;
1229 # $maxwidth += $formatters->[$col]{width};
1230 }
1231 22 for my $col (0..$#parts) {
1232 66 my $f = $formatters->[$col];
1233 66 ▶ push @{$parts[$col]}, ("") x max(0,($f->{height}{min}||0)-@{$parts[$col]});
Condition50%1/2
$f->{'height'}{'min'} || 0
l!l
066
MC/DC0%0/1
$f->{'height'}{'min'} || 0
$f->{'height'}{'min'}
Truth table50%1/2
A
A= $f->{'height'}{'min'}
Aresult
11
00
1234 66 my $fopts = $f->{opts};
1235 66 ▶ my $tfill = first {defined $_} @{$fopts}{qw(tfill vfill fill)}, " ";
Subroutine __ANON__: called CC=1 SCAR=0.0
1236 66 ▶ my $bfill = first {defined $_} @{$fopts}{qw(bfill vfill fill)}, " ";
Subroutine __ANON__: called CC=1 SCAR=0.0
1237 66 ▶ my $lfill = first {defined $_} @{$fopts}{qw(lfill hfill fill)}, " ";
Subroutine __ANON__: called CC=1 SCAR=0.0
1238 66 ▶ my $rfill = first {defined $_} @{$fopts}{qw(rfill hfill fill)}, " ";
Subroutine __ANON__: called CC=1 SCAR=0.0
1239 66 $f->{vjust}->($maxheight,$tfill,$bfill,$parts[$col]);
1240 66 for my $row (0..$#{$parts[$col]}) {
1241 66 my $last = $parts[$col][$row] =~ s/\r//;
1242 $f->{hjust}->($parts[$col][$row], pre=>$lfill, post=>$rfill,
1243 last=>$last, pos=>$f->{pos},
1244 stretch=>$f->{stretch}, width=>$f->{width},
1245 66 );
1246 }
1247 }
1248 22 for my $row (0..$maxheight) {
1249 push @text, join "",
1250 44 grep { defined } map $parts[$_][$row],0..$#parts;
1251 }
1252 }
1253 22 return (\@text, $more);
1254 }
1255  
1256 # Extract perpendicular cross-sections from an AoA, AoH, HoA, HoH, AoHoA, etc.
1257  
1258 0 ▶sub section {
Subroutine section: not called CC=11 SCAR=48.8
Pod undocumented
1259 0 my ($structure, @index) = @_;
1260 0 ▶ $structure = [ values %$structure ] if ref $structure eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $structure eq "HASH" 0 0 0
1261 0 my @section;
1262 0 for my $row ( @$structure ) {
1263 0 local $,=",";
1264 0 ▶ my $type = ref $row or croak "Too many indices (starting with [@index])";
Branch: 1 branch
BranchTrueFalseTotal
my $type = ref $row or croak("Too many indices (starting with [@index])") 0 0 0
1265 0 ▶ if ($type eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'HASH') { } 0 0 0
elsif ($type eq 'ARRAY') { } 0 0 0
1266 0 ▶ @index = keys %$row unless @index;
Branch: 1 branch
BranchTrueFalseTotal
unless @index 0 0 0
1267 0 push @{$section[$_]}, $row->{$index[$_]} for 0..$#index;
1268 }
1269 elsif ($type eq 'ARRAY') {
1270 0 ▶ @index = (0..$#$row) unless @index;
Branch: 1 branch
BranchTrueFalseTotal
unless @index 0 0 0
1271 0 push @{$section[$_]}, $row->[$index[$_]] for 0..$#index;
1272 }
1273 else {
1274 0 my $what = ref $structure;
1275 0 ▶ croak "Can't drill ", ($what ? lc $what : $structure) , " of $type";
Branch: 1 branch
BranchTrueFalseTotal
$what ? : 0 0 0
1276 }
1277 }
1278 0 return @section;
1279 }
1280  
1281 0 ▶sub slice {
Subroutine slice: not called CC=3 SCAR=24.8
Pod undocumented
1282 0 my ($structure, @indices) = @_;
1283 0 ▶ return ref eq 'HASH' ? @{$_}{@indices} : @{$_}[@indices] for $structure;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'HASH' ? : 0 0 0
1284 }
1285  
1286 0 ▶sub vals { return ref eq 'HASH' ? values %$_ : @$_ for $_[0] }
Subroutine vals: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'HASH' ? : 0 0 0
1287  
1288 2 ▶sub drill (\[@%];@) is export {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=2 SCAR=6.9
Subroutine drill: not called CC=5 SCAR=25.6
Pod undocumented
1289 0 my ($structure, @indices) = @_;
1290 0 ▶ return $structure unless @indices;
Branch: 1 branch
BranchTrueFalseTotal
unless @indices 0 0 0
1291 0 my $index = shift @indices;
1292 0 ▶ my @section = [ @$index ? slice($structure,@$index) : vals($structure) ];
Branch: 1 branch
BranchTrueFalseTotal
@$index ? : 0 0 0
1293 0 ▶ return @section unless @indices;
Branch: 1 branch
BranchTrueFalseTotal
unless @indices 0 0 0
1294 0 for my $index (@indices) {
1295 0 @section = map {section $_, @$index} @section;
1296 }
1297 0 return @section;
1298 }
1299  
1300 44 ▶sub break_lit {
Subroutine break_lit: called CC=1 SCAR=0.0
Pod undocumented
1301 44 return (${$_[0]},0,0);
1302 }
1303  
1304 0 ▶sub break_bullet {
Subroutine break_bullet: not called CC=2 SCAR=17.9
Pod undocumented
1305 0 my ($src) = @_;
1306 0 ▶ my $next = pop @$src || "";
Condition0%0/2
pop @$src || ''
l!l
00
MC/DC0%0/1
pop @$src || ''
pop @$src
Truth table0%0/2
A
A= pop @$src
Aresult
11
00
1307 0 return ($next,@$src>0,0);
1308 }
1309  
1310 0 ▶sub break_verbatim {
Subroutine break_verbatim: not called CC=3 SCAR=24.8
Pod undocumented
1311 0 my ($str,$rem) = @_;
1312 0 ▶ $$str =~ m/ \G ([^\n\r]*) (?:\r|\n|\z) /gcx or return ("",0);
Branch: 1 branch
BranchTrueFalseTotal
$$str =~ / \G ([^\n\r]*) (?:\r|\n|\z) /cgx or return "", 0 0 0 0
1313 0 ▶ return (substr("$1",0,$rem), $$str =~ m/ \G (?=.) /sgcx ? 1 : 0,0);
Branch: 1 branch
BranchTrueFalseTotal
$$str =~ / \G (?=.) /cgsx ? : 0 0 0
1314 }
1315  
1316 22 ▶sub break_nl {
Subroutine break_nl: called CC=3 SCAR=12.5
Pod undocumented
1317 22 my ($str) = @_;
1318 22 ▶ if ($$str =~ m/\G [^\S\n\r]* ([^\n\r]*?) [^\S\r\n]* (?:\r|$)/gcxm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$str =~ /\G [^\S\n\r]* ([^\n\r]*?) [^\S\r\n]* (?:\r|$)/cgmx) { } 22 0 22
1319 22 ▶ return ("$1", $$str =~ /\G(?=.*\S)/sgc?1:0, 1);
Branch: 1 branch
BranchTrueFalseTotal
$$str =~ /\G(?=.*\S)/cgs ? : 0 22 22
1320 }
1321 else {
1322 0 return ("",0,0);
1323 }
1324 }
1325  
1326 2 my $wsnzw = q{ (??{length($^N)?'(?=)':'(?!)'}) };
1327  
1328 2 ▶sub break_at is export {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=2 SCAR=6.9
Subroutine break_at: called CC=1 SCAR=4.6
Pod undocumented
1329 2 my ($hyphen) = @_;
1330 2 my ($lit_hy) = qr/\Q$hyphen\E/;
1331 2 my $hylen = length($hyphen);
1332 2 my @ret;
1333 0 ▶ return sub {
Subroutine __ANON__: not called CC=22 SCAR=61.2
1334 0 my ($str,$rem,$ws) = @_;
1335 0 my ($last_breakable, $res) = ($rem+1,"", 0);
1336 0 for ($$str) {
1337 2 ▶ use re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
1338 0 ▶ while ($rem > 0 && (pos()||0) < length()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem > 0 and (pos $_ || 0) < length $_) 0 0 0
Condition0%0/5
$rem > 0 and (pos $_ || 0) < length $_
!ll&&!rl&&r
000
pos $_ || 0
l!l
00
MC/DC0%0/2
$rem > 0 and (pos $_ || 0) < length $_
$rem > 0 pos $_
Truth table0%0/3
A and B
A= $rem > 0B= pos $_
ABresult
0X0
100
111
1339 0 ▶ if ($ws && /\G ($ws) $wsnzw/gcx) {
Branch: 3 branches
BranchTrueFalseTotal
if ($ws and /\G ($ws) $wsnzw/cgx) { } 0 0 0
elsif ($rem >= $hylen and /\G $lit_hy /cgx) { } 0 0 0
elsif (/\G ((?!$lit_hy)[^\n\r]) /cgx) { } 0 0 0
Condition0%0/3
$ws and /\G ($ws) $wsnzw/cgx
!ll&&!rl&&r
000
MC/DC0%0/2
$ws and /\G ($ws) $wsnzw/cgx
$ws /\G ($ws) $wsnzw/cgx
Truth table0%0/3
A and B
A= $wsB= /\G ($ws) $wsnzw/cgx
ABresult
0X0
100
111
1340 0 my $captured;
1341 0 ▶ if ($#+ > 1) { # may be extra captures...
Branch: 1 branch
BranchTrueFalseTotal
if ($#+ > 1) 0 0 0
1342 0 for (2..$#+) {
1343 0 ▶ next unless defined $$_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$_ 0 0 0
1344 0 $captured++;
1345 0 $res .= $$_;
1346 0 $rem -= length $$_;
1347 }
1348 }
1349 0 ▶ unless ($captured) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($captured) 0 0 0
1350 0 $res .= $1;
1351 0 $rem--;
1352 }
1353 0 $last_breakable = length $res;
1354 }
1355 ▶ elsif ($rem>=$hylen && /\G $lit_hy /gcx) {
Condition0%0/3
$rem >= $hylen and /\G $lit_hy /cgx
!ll&&!rl&&r
000
MC/DC0%0/2
$rem >= $hylen and /\G $lit_hy /cgx
$rem >= $hylen /\G $lit_hy /cgx
Truth table0%0/3
A and B
A= $rem >= $hylenB= /\G $lit_hy /cgx
ABresult
0X0
100
111
1356 0 $res .= $hyphen;
1357 0 $rem -= $hylen;
1358 0 $last_breakable = length $res;
1359 }
1360 elsif (/\G ((?!$lit_hy)[^\n\r]) /gcx) {
1361 0 $res .= $1;
1362 0 $rem--;
1363 0 ▶ $last_breakable = length $res if $res =~ /\s$/;
Branch: 1 branch
BranchTrueFalseTotal
if $res =~ /\s$/ 0 0 0
1364 }
1365 0 else { last }
1366 }
1367 0 my $reslen = length $res;
1368 0 ▶ $ws ||= qr/\s/;
Condition0%0/2
$ws ||= qr/\s/
l!l
00
MC/DC0%0/1
$ws ||= qr/\s/
$ws
Truth table0%0/2
A
A= $ws
Aresult
11
00
1369 0 ▶ unless (/\G (?=$lit_hy|($ws)$wsnzw|\z|\n|\r) /gcx) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G (?=$lit_hy|($ws)$wsnzw|\z|\n|\r) /cgx) 0 0 0
1370 0 ▶ if ($last_breakable <= $reslen) {
Branch: 2 branches
BranchTrueFalseTotal
if ($last_breakable <= $reslen) { } 0 0 0
elsif ($reslen > $hylen) { } 0 0 0
1371 0 pos() -= $reslen-$last_breakable;
1372 0 substr($res,$last_breakable) = "";
1373 }
1374 elsif ($reslen > $hylen) {
1375 0 ▶ if ($res =~ /\S\S\S{$hylen}$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res =~ /\S\S\S{$hylen}$/) { } 0 0 0
elsif ($res =~ s/(\S+)$//) { } 0 0 0
1376 0 pos() -= $hylen;
1377 0 substr($res,-$hylen) = $hyphen;
1378 }
1379 elsif ($res =~ s/(\S+)$//) {
1380 0 pos() -= length($1);
1381 }
1382 }
1383 }
1384 0 my $rem = substr($$str, pos $$str);
1385 0 ▶ return ($res, $rem=~/\S/?1:0, $rem =~ /^\s*(?:\z|\n|\r)/);
Branch: 1 branch
BranchTrueFalseTotal
$rem =~ /\S/ ? : 0 0 0
1386 }
1387 2 };
1388 }
1389  
1390 2 ▶sub import {
Subroutine _import_2a663ceacd2d6597b91d59b4f6eddce3: called CC=3 SCAR=13.3
1391 2 my $class = shift;
1392 2 my ($package, $file, $line) = caller;
1393 2 my %opts;
1394 2 for (@_) {
1395 0 ▶ croak "Options for $class must be specified in a hash"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ eq "HASH" 0 0 0
1396 unless ref eq 'HASH';
1397 0 update(%opts, %$_, 'croak');
1398 }
1399 2 $caller_opts{$package,$file}{$line} = \%opts;
1400 }
1401  
1402 package Perl6::Form::Rule::Fail;
1403 use overload
1404 0 ▶ '""' => sub{ undef },
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=6.9
1405 0 ▶ '0+' => sub{ undef },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1406 0 ▶ 'bool' => sub{ 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1407 2 ;
1408  
1409 package Perl6::Form::Rule::Okay;
1410 use overload
1411 0 ▶ '""' => sub{ $_[0][0] },
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=6.9
1412 0 ▶ '0+' => sub{ $_[0][0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1413 0 ▶ 'bool' => sub{ 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1414 2 ;
1415  
1416 2 1;
1417 __END__
↑ Summary