blib/lib/Term/Fabulous/Widget/Table/Borders.pm

filter: Statementstmt 100% 142 / 142 Branchbran 100% 104 / 104 Conditioncond 86.7% 85 / 98 MC/DCmcdc 75.0% 45 / 60 Subroutinesub 100% 28 / 28 Podpod 100% 1 / 1 totaltotal 93.5% 405 / 433 CC 94 SCAR 24.8
CC
94
Cov
96%
resolve_borders
26.0
__ANON__
15.1
__ANON__
14.0
CRAP 12.0
« blib/lib/Term/Fabulous/Chart/Format.pm ↑ Summary blib/lib/Term/Fabulous/Widget/Table/Frame.pm »
1 package Term::Fabulous::Widget::Table::Borders;
2  
3 1 ▶use v5.32;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.03';
9  
10 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 our @EXPORT_OK = qw(resolve_borders);
12  
13 1 ▶use List::Util qw(any first);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Term::Fabulous::Enum::BorderStyle;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 my $HIDDEN = Term::Fabulous::Enum::BorderStyle->Hidden;
18 1 my $BLANK = Term::Fabulous::Enum::BorderStyle->Blank;
19  
20 70 ▶sub _is_line ($style) {
Subroutine _is_line: called CC=3 SCAR=11.1
21 70 ▶ return defined $style && refaddr($style) != refaddr($HIDDEN) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $style && builtin::refaddr($style) != builtin::refaddr($HIDDEN) ? : 67 3 70
Condition66%2/3
defined $style and builtin::refaddr($style) != builtin::refaddr($HIDDEN)
!ll&&!rl&&r
0367
MC/DC50%1/2
defined $style and builtin::refaddr($style) != builtin::refaddr($HIDDEN)
defined $style builtin::refaddr($style) != builtin::refaddr($HIDDEN)
Truth table66%2/3
A and B
A= defined $styleB= builtin::refaddr($style) != builtin::refaddr($HIDDEN)
ABresult
0X0
100
111
22 }
23  
24 # Whether a style has joint glyphs, so that its lines join with others.
25 84 ▶sub _joins ($style) {
Subroutine _joins: called CC=2 SCAR=6.9
26 84 ▶ return defined $style->joints ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $style->joints ? : 60 24 84
27 }
28  
29 # Whether a frame side is drawn on the background outside the table
30 # (see Term::Fabulous::Role::HasBorderStyle/outer_border_sides). Line
31 # styles are, so that highlights stop at the frame. Block styles (Outer,
32 # Inner, Thick, ...) keep the backgrounds their glyphs are made for: a
33 # side whose glyph sits on the cell's own background stays inside, so the
34 # cells' colors reach the frame; one whose glyph sits on the background
35 # beside the box (location 1 or 2) is outside, and so are the cells of
36 # other lines that end on it.
37 44 ▶sub _drawn_outside ( $style, $side ) {
Subroutine _drawn_outside: called CC=7 SCAR=19.5
38 44 ▶ return 1 if _joins($style);
Branch: 1 branch
BranchTrueFalseTotal
if _joins($style) 32 12 44
39 12 ▶ my $location
Branch: 3 branches
BranchTrueFalseTotal
$side eq 'top' ? : 3 9 12
$side eq 'bottom' ? : 3 6 9
$side eq 'left' ? : 3 3 6
40 = $side eq 'top' ? ( $style->get_top_locations )[1]
41 : $side eq 'bottom' ? ( $style->get_bottom_locations )[1]
42 : $side eq 'left' ? $style->get_left_locations
43 : $style->get_right_locations;
44 12 ▶ return $location == 1 || $location == 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$location == 1 || $location == 2 ? : 4 8 12
Condition66%2/3
$location == 1 or $location == 2
l!l&&r!l&&!r
408
MC/DC50%1/2
$location == 1 or $location == 2
$location == 1 $location == 2
Truth table66%2/3
A or B
A= $location == 1B= $location == 2
ABresult
1X1
011
000
45 }
46  
47 # The first style the levels name, from the most specific: a level is an
48 # array of candidates, the last one winning within the level (the cell
49 # below, or to the right). Hidden ends the search: there is no line.
50 105 ▶sub _first_style (@levels) {
Subroutine _first_style: called CC=4 SCAR=13.9
51 105 foreach my $level (@levels) {
52 399 ▶ my $style = first { defined } reverse @$level;
Subroutine __ANON__: called CC=1 SCAR=0.0
53 399 ▶ return _is_line($style) ? $style : undef if defined $style;
Branch: 2 branches
BranchTrueFalseTotal
if defined $style 70 329 399
_is_line($style) ? : 67 3 70
54 }
55 35 return undef;
56 }
57  
58 # Works out the lines of a table. Takes
59 # columns => the number of grid columns
60 # header => how many of the lines are header lines (they come first)
61 # table => { border_top, border_right, border_bottom, border_left,
62 # column_lines, row_lines, header_line }
63 # column_styles => [ per column { border_left, border_right, row_lines } ]
64 # lines => [ per line { spanning, style => { border_top, border_right,
65 # border_bottom, border_left, column_lines },
66 # cells => [ per cell { border_top, border_right,
67 # border_bottom, border_left } ] } ] (a spanning line has
68 # one cell)
69 # and returns, per line, per cell: { sides => { top, right, bottom, left }
70 # (a BorderStyle per drawn side, Blank where a line passes elsewhere but
71 # not here), corners => { top_left, ... } (the glyph of every drawn
72 # corner that does not keep the glyph of its style) }.
73 7 ▶sub resolve_borders (%args) {
Subroutine resolve_borders: called CC=26 SCAR=32.6
Pod documented
74 7 my ( $columns, $lines ) = @args{qw(columns lines)};
75 7 ▶ my $header_lines = $args{header} // 0;
Condition100%2/2
$args{"header"} // 0
l!l
25
MC/DC100%1/1
$args{"header"} // 0
$args{"header"}
Truth table100%2/2
A
A= $args{"header"}
Aresult
11
00
76 7 ▶ my $table = $args{table} // {};
Condition50%1/2
$args{"table"} // {}
l!l
70
MC/DC0%0/1
$args{"table"} // {}
$args{"table"}
Truth table50%1/2
A
A= $args{"table"}
Aresult
11
00
77 7 ▶ my $column_style = $args{column_styles} // [];
Condition100%2/2
$args{"column_styles"} // []
l!l
16
MC/DC100%1/1
$args{"column_styles"} // []
$args{"column_styles"}
Truth table100%2/2
A
A= $args{"column_styles"}
Aresult
11
00
78 7 my $last_line = $#$lines;
79 7 my $line_count = scalar @$lines;
80  
81 146 ▶ my $cell_style = sub ( $line, $column ) {
Subroutine __ANON__: called CC=4 SCAR=13.9
82 146 ▶ my $cells = $lines->[$line]{cells} // [];
Condition100%2/2
$lines->[$line]{"cells"} // []
l!l
20126
MC/DC100%1/1
$lines->[$line]{"cells"} // []
$lines->[$line]{"cells"}
Truth table100%2/2
A
A= $lines->[$line]{"cells"}
Aresult
11
00
83 146 ▶ return ( $lines->[$line]{spanning} ? $cells->[0] : $cells->[$column] ) // {};
Branch: 1 branch
BranchTrueFalseTotal
$lines->[$line]{'spanning'} ? : 6 140 146
Condition100%2/2
($lines->[$line]{"spanning"} ? $cells->[0] : $cells->[$column]) // {}
l!l
20126
MC/DC100%1/1
($lines->[$line]{"spanning"} ? $cells->[0] : $cells->[$column]) // {}
($lines->[$line]{"spanning"} ? $cells->[0] : $cells->[$column])
Truth table100%2/2
A
A= ($lines->[$line]{"spanning"} ? $cells->[0] : $cells->[$column])
Aresult
11
00
84 7 };
85 7 ▶ my $row_style = sub ($line) { $lines->[$line]{style} // {} };
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$lines->[$line]{"style"} // {}
l!l
14113
MC/DC100%1/1
$lines->[$line]{"style"} // {}
$lines->[$line]{"style"}
Truth table100%2/2
A
A= $lines->[$line]{"style"}
Aresult
11
00
86  
87 # The horizontal segment above line $boundary ($line_count: below the
88 # last line) in a column.
89 52 ▶ my $horizontal = sub ( $boundary, $column ) {
Subroutine __ANON__: called CC=13 SCAR=25.7
90 52 my ( $above, $below ) = ( $boundary - 1, $boundary );
91 52 ▶ my @cells = ( ( $above >= 0 ? $cell_style->( $above, $column )->{border_bottom} : undef ), ( $below < $line_count ? $cell_style->( $below, $column )->{border_top} : undef ) );
Branch: 2 branches
BranchTrueFalseTotal
$above >= 0 ? : 37 15 52
$below < $line_count ? : 37 15 52
92 52 ▶ my @rows = ( ( $above >= 0 ? $row_style->($above)->{border_bottom} : undef ), ( $below < $line_count ? $row_style->($below)->{border_top} : undef ) );
Branch: 2 branches
BranchTrueFalseTotal
$above >= 0 ? : 37 15 52
$below < $line_count ? : 37 15 52
93 52 ▶ my $inner = $boundary > 0 && $boundary < $line_count;
Condition100%3/3
$boundary > 0 && $boundary < $line_count
!ll&&!rl&&r
151522
MC/DC100%2/2
$boundary > 0 && $boundary < $line_count
$boundary > 0 $boundary < $line_count
Truth table100%3/3
A && B
A= $boundary > 0B= $boundary < $line_count
ABresult
0X0
100
111
94 52 ▶ my @columns = $inner && $boundary != $header_lines ? ( ( $column_style->[$column] // {} )->{row_lines} ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$inner && $boundary != $header_lines ? : 18 34 52
Condition100%5/5
$inner and $boundary != $header_lines
!ll&&!rl&&r
30418
$column_style->[$column] // {}
l!l
612
MC/DC100%2/2
$inner and $boundary != $header_lines
$inner $boundary != $header_lines
MC/DC100%1/1
$column_style->[$column] // {}
$column_style->[$column]
Truth table100%3/3
A and B
A= $innerB= $boundary != $header_lines
ABresult
0X0
100
111
Truth table100%2/2
A
A= $column_style->[$column]
Aresult
11
00
95 my $table_line
96 = $boundary == 0 ? $table->{border_top}
97 : $boundary == $line_count ? $table->{border_bottom}
98 : $boundary == $header_lines ? $table->{header_line} // $table->{row_lines}
99 52 ▶ : $table->{row_lines};
Branch: 3 branches
BranchTrueFalseTotal
$boundary == 0 ? : 15 37 52
$boundary == $line_count ? : 15 22 37
$boundary == $header_lines ? : 4 18 22
Condition33%1/3
$table->{"header_line"} // $table->{"row_lines"}
l!l&&r!l&&!r
400
MC/DC0%0/2
$table->{"header_line"} // $table->{"row_lines"}
$table->{"header_line"} $table->{"row_lines"}
Truth table33%1/3
A // B
A= $table->{"header_line"}B= $table->{"row_lines"}
ABresult
1X1
011
000
100 52 return _first_style( \@cells, \@rows, \@columns, [$table_line] );
101 7 };
102  
103 # The vertical segment of a line left of grid column $boundary
104 # ($columns: right of the last column).
105 54 ▶ my $vertical = sub ( $line, $boundary ) {
Subroutine __ANON__: called CC=14 SCAR=26.4
106 54 my $spanning = $lines->[$line]{spanning};
107 54 ▶ my $outer = $boundary == 0 || $boundary == $columns;
Condition100%3/3
$boundary == 0 || $boundary == $columns
l!l&&r!l&&!r
171720
MC/DC100%2/2
$boundary == 0 || $boundary == $columns
$boundary == 0 $boundary == $columns
Truth table100%3/3
A || B
A= $boundary == 0B= $boundary == $columns
ABresult
1X1
011
000
108 54 ▶ return undef if $spanning && !$outer;
Branch: 1 branch
BranchTrueFalseTotal
if $spanning and not $outer 1 53 54
Condition100%3/3
$spanning and not $outer
!ll&&!rl&&r
5121
MC/DC100%2/2
$spanning and not $outer
$spanning not $outer
Truth table100%3/3
A and not(B)
A= $spanningB= not $outer
ABresult
0X0
100
111
109 my @cells = (
110 ( $boundary > 0 ? $cell_style->( $line, $boundary - 1 )->{border_right} : undef ),
111 53 ▶ ( $boundary < $columns ? $cell_style->( $line, $boundary )->{border_left} : undef ),
Branch: 2 branches
BranchTrueFalseTotal
$boundary > 0 ? : 36 17 53
$boundary < $columns ? : 36 17 53
112 );
113 53 my $row = $row_style->($line);
114 my @rows
115 = $boundary == 0 ? ( $row->{border_left} )
116 : $boundary == $columns ? ( $row->{border_right} )
117 53 ▶ : ( $row->{column_lines} );
Branch: 2 branches
BranchTrueFalseTotal
$boundary == 0 ? : 17 36 53
$boundary == $columns ? : 17 19 36
118 my @column_levels = (
119 ( $boundary > 0 ? ( $column_style->[ $boundary - 1 ] // {} )->{border_right} : undef ),
120 53 ▶ ( $boundary < $columns ? ( $column_style->[$boundary] // {} )->{border_left} : undef ),
Branch: 2 branches
BranchTrueFalseTotal
$boundary > 0 ? : 36 17 53
$boundary < $columns ? : 36 17 53
Condition100%4/4
$$column_style[$boundary - 1] // {}
l!l
828
$column_style->[$boundary] // {}
l!l
828
MC/DC100%1/1
$$column_style[$boundary - 1] // {}
$$column_style[$boundary - 1]
MC/DC100%1/1
$column_style->[$boundary] // {}
$column_style->[$boundary]
Truth table100%2/2
A
A= $$column_style[$boundary - 1]
Aresult
11
00
Truth table100%2/2
A
A= $column_style->[$boundary]
Aresult
11
00
121 );
122 53 ▶ my $table_line = $boundary == 0 ? $table->{border_left} : $boundary == $columns ? $table->{border_right} : $table->{column_lines};
Branch: 2 branches
BranchTrueFalseTotal
$boundary == 0 ? : 17 36 53
$boundary == $columns ? : 17 19 36
123 53 return _first_style( \@cells, \@rows, \@column_levels, [$table_line] );
124 7 };
125  
126 7 my ( @h, @v );
127 7 foreach my $boundary ( 0 .. $line_count ) {
128 24 $h[$boundary] = [ map { $horizontal->( $boundary, $_ ) } 0 .. $columns - 1 ];
129 }
130 7 foreach my $line ( 0 .. $last_line ) {
131 17 $v[$line] = [ map { $vertical->( $line, $_ ) } 0 .. $columns ];
132 }
133 my @row_line_exists = map {
134 7 my $boundary = $_;
135 24 ▶ ( any { defined } @{ $h[$boundary] } ) ? 1 : 0
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
&any(sub { defined $_; } , @{$h[$boundary];}) ? : 16 8 24
136 } 0 .. $line_count;
137 my @column_line_exists = map {
138 7 my $boundary = $_;
139 22 ▶ ( any { defined $v[$_][$boundary] } 0 .. $last_line ) ? 1 : 0
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
&any(sub { defined $v[$_][$boundary]; } , 0 .. $last_line) ? : 15 7 22
140 } 0 .. $columns;
141  
142 # Who draws a horizontal boundary: the line below it, except that a
143 # boundary above a spanning line is drawn by the (non-spanning) line
144 # above it, the last boundary by the last line, and the boundary below
145 # the header by the header, which does not scroll.
146 22 ▶ my $drawn_as_bottom = sub ($boundary) {
Subroutine __ANON__: called CC=6 SCAR=17.9
147 22 ▶ return 1 if $boundary == $line_count;
Branch: 1 branch
BranchTrueFalseTotal
if $boundary == $line_count 5 17 22
148 17 ▶ return 0 if $boundary == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $boundary == 0 5 12 17
149 12 ▶ return 1 if $boundary == $header_lines;
Branch: 1 branch
BranchTrueFalseTotal
if $boundary == $header_lines 4 8 12
150 8 ▶ return $lines->[$boundary]{spanning} && !$lines->[ $boundary - 1 ]{spanning} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$lines->[$boundary]{'spanning'} && !$$lines[$boundary - 1]{'spanning'} ? : 2 6 8
Condition66%2/3
$lines->[$boundary]{"spanning"} and not $$lines[$boundary - 1]{"spanning"}
!ll&&!rl&&r
602
MC/DC50%1/2
$lines->[$boundary]{"spanning"} and not $$lines[$boundary - 1]{"spanning"}
$lines->[$boundary]{"spanning"} not $$lines[$boundary - 1]{"spanning"}
Truth table66%2/3
A and not(B)
A= $lines->[$boundary]{"spanning"}B= not $$lines[$boundary - 1]{"spanning"}
ABresult
0X0
100
111
151 7 };
152  
153 92 ▶ my $vertical_arm = sub ( $line, $boundary ) {
Subroutine __ANON__: called CC=3 SCAR=11.0
154 92 ▶ return undef if $line < 0 || $line > $last_line;
Branch: 1 branch
BranchTrueFalseTotal
if $line < 0 or $line > $last_line 28 64 92
Condition100%3/3
$line < 0 or $line > $last_line
l!l&&r!l&&!r
141464
MC/DC100%2/2
$line < 0 or $line > $last_line
$line < 0 $line > $last_line
Truth table100%3/3
A or B
A= $line < 0B= $line > $last_line
ABresult
1X1
011
000
155 64 return $v[$line][$boundary];
156 7 };
157 92 ▶ my $horizontal_arm = sub ( $boundary, $column ) {
Subroutine __ANON__: called CC=3 SCAR=11.0
158 92 ▶ return undef if $column < 0 || $column >= $columns;
Branch: 1 branch
BranchTrueFalseTotal
if $column < 0 or $column >= $columns 32 60 92
Condition100%3/3
$column < 0 or $column >= $columns
l!l&&r!l&&!r
161660
MC/DC100%2/2
$column < 0 or $column >= $columns
$column < 0 $column >= $columns
Truth table100%3/3
A or B
A= $column < 0B= $column >= $columns
ABresult
1X1
011
000
159 60 return $h[$boundary][$column];
160 7 };
161  
162 # The glyph of a point of the outer frame when the frame's style has no
163 # joints (Outer, Inner, Thick, ...): the frame runs on with its straight
164 # edge glyph where an inner line meets it, and keeps its own corner
165 # glyphs at the table's corners (undef: no glyph of the table's own).
166 # Returns ( 1, $glyph ) for such a point, () for any other.
167 46 ▶ my $frame_point = sub ( $boundary, $grid_line, $arms ) {
Subroutine __ANON__: called CC=15 SCAR=27.1
168 46 my $on_top = $boundary == 0;
169 46 my $on_bottom = $boundary == $line_count;
170 46 ▶ my $on_side = $grid_line == 0 || $grid_line == $columns;
Condition100%3/3
$grid_line == 0 || $grid_line == $columns
l!l&&r!l&&!r
161614
MC/DC100%2/2
$grid_line == 0 || $grid_line == $columns
$grid_line == 0 $grid_line == $columns
Truth table100%3/3
A || B
A= $grid_line == 0B= $grid_line == $columns
ABresult
1X1
011
000
171 my $edge
172 = $on_top || $on_bottom ? $arms->{left} // $arms->{right}
173 : $on_side ? $arms->{up} // $arms->{down}
174 46 ▶ : undef;
Branch: 2 branches
BranchTrueFalseTotal
$on_top || $on_bottom ? : 28 18 46
$on_side ? : 12 6 18
Condition66%6/9
$on_top or $on_bottom
l!l&&r!l&&!r
141418
$arms->{"left"} // $arms->{"right"}
l!l&&r!l&&!r
18100
$arms->{"up"} // $arms->{"down"}
l!l&&r!l&&!r
1200
MC/DC100%2/2
$on_top or $on_bottom
$on_top $on_bottom
MC/DC0%0/2
$arms->{"left"} // $arms->{"right"}
$arms->{"left"} $arms->{"right"}
MC/DC0%0/2
$arms->{"up"} // $arms->{"down"}
$arms->{"up"} $arms->{"down"}
Truth table100%3/3
A or B
A= $on_topB= $on_bottom
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $arms->{"left"}B= $arms->{"right"}
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $arms->{"up"}B= $arms->{"down"}
ABresult
1X1
011
000
175 46 ▶ return () unless defined $edge && !_joins($edge);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $edge and not _joins($edge) 34 12 46
Condition100%3/3
defined $edge and not _joins($edge)
!ll&&!rl&&r
62812
MC/DC100%2/2
defined $edge and not _joins($edge)
defined $edge not _joins($edge)
Truth table100%3/3
A and not(B)
A= defined $edgeB= not _joins($edge)
ABresult
0X0
100
111
176 12 ▶ return ( 1, undef ) if ( $on_top || $on_bottom ) && $on_side;
Branch: 1 branch
BranchTrueFalseTotal
if $on_top || $on_bottom and $on_side 8 4 12
Condition100%6/6
$on_top || $on_bottom and $on_side
!ll&&!rl&&r
228
$on_top or $on_bottom
l!l&&r!l&&!r
552
MC/DC100%3/3
$on_top || $on_bottom and $on_side
$on_top $on_bottom $on_side
Truth table100%5/5
A or B and C
A= $on_topB= $on_bottomC= $on_side
ABCresult
00X0
1X00
0100
1X11
0111
177 4 ▶ return ( 1, ( $edge->get_top_glyphs )[1] ) if $on_top;
Branch: 1 branch
BranchTrueFalseTotal
if $on_top 1 3 4
178 3 ▶ return ( 1, ( $edge->get_bottom_glyphs )[1] ) if $on_bottom;
Branch: 1 branch
BranchTrueFalseTotal
if $on_bottom 1 2 3
179 2 ▶ return ( 1, ( $grid_line == 0 ? $edge->get_left_glyphs : $edge->get_right_glyphs ) );
Branch: 1 branch
BranchTrueFalseTotal
$grid_line == 0 ? : 1 1 2
180 7 };
181 46 ▶ my $corner = sub ( $boundary, $grid_line ) {
Subroutine __ANON__: called CC=3 SCAR=11.0
182 46 my %arms = (
183 up => $vertical_arm->( $boundary - 1, $grid_line ),
184 down => $vertical_arm->( $boundary, $grid_line ),
185 left => $horizontal_arm->( $boundary, $grid_line - 1 ),
186 right => $horizontal_arm->( $boundary, $grid_line ),
187 );
188 46 my ( $on_frame, $frame_glyph ) = $frame_point->( $boundary, $grid_line, \%arms );
189 46 ▶ return $frame_glyph if $on_frame;
Branch: 1 branch
BranchTrueFalseTotal
if $on_frame 12 34 46
190 34 ▶ return Term::Fabulous::Enum::BorderStyle->junction(%arms) // ' ';
Condition50%1/2
"Term::Fabulous::Enum::BorderStyle"->junction(%arms) // " "
l!l
340
MC/DC0%0/1
"Term::Fabulous::Enum::BorderStyle"->junction(%arms) // " "
"Term::Fabulous::Enum::BorderStyle"->junction(%arms)
Truth table50%1/2
A
A= "Term::Fabulous::Enum::BorderStyle"->junction(%arms)
Aresult
11
00
191 7 };
192 83 ▶ my $side_style = sub ( $exists, $style ) {
Subroutine __ANON__: called CC=3 SCAR=11.1
193 83 ▶ return undef unless $exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $exists 14 69 83
194 69 ▶ return $style // $BLANK;
Condition66%2/3
$style // $BLANK
l!l&&r!l&&!r
6720
MC/DC0%0/2
$style // $BLANK
$style $BLANK
Truth table66%2/3
A // B
A= $styleB= $BLANK
ABresult
1X1
011
000
195 7 };
196  
197 7 my @result;
198 7 foreach my $line ( 0 .. $last_line ) {
199 17 my $spanning = $lines->[$line]{spanning};
200 17 ▶ my @cell_columns = $spanning ? ( [ 0, $columns - 1 ] ) : map { [ $_, $_ ] } 0 .. $columns - 1;
Branch: 1 branch
BranchTrueFalseTotal
$spanning ? : 1 16 17
201 17 ▶ my $top_drawn = $row_line_exists[$line] && !$drawn_as_bottom->($line);
Condition100%3/3
$row_line_exists[$line] && !&$drawn_as_bottom($line)
!ll&&!rl&&r
638
MC/DC100%2/2
$row_line_exists[$line] && !&$drawn_as_bottom($line)
$row_line_exists[$line] !&$drawn_as_bottom($line)
Truth table100%3/3
A && not(B)
A= $row_line_exists[$line]B= !&$drawn_as_bottom($line)
ABresult
0X0
100
111
202 17 ▶ my $bottom_drawn = $row_line_exists[ $line + 1 ] && $drawn_as_bottom->( $line + 1 );
Condition100%3/3
$row_line_exists[$line + 1] && &$drawn_as_bottom($line + 1)
!ll&&!rl&&r
638
MC/DC100%2/2
$row_line_exists[$line + 1] && &$drawn_as_bottom($line + 1)
$row_line_exists[$line + 1] &$drawn_as_bottom($line + 1)
Truth table100%3/3
A && B
A= $row_line_exists[$line + 1]B= &$drawn_as_bottom($line + 1)
ABresult
0X0
100
111
203 17 my @cells;
204 17 foreach my $span (@cell_columns) {
205 36 my ( $first, $last ) = @$span;
206 my %sides = (
207 left => $side_style->( $column_line_exists[$first], $v[$line][$first] ),
208 right => ( $last == $columns - 1 ? $side_style->( $column_line_exists[$columns], $v[$line][$columns] ) : undef ),
209 15 ▶ top => ( $top_drawn ? $side_style->( 1, first { defined } @{ $h[$line] }[ $first .. $last ] ) : undef ),
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$bottom_drawn ? : 15 21 36
210 36 ▶ bottom => ( $bottom_drawn ? $side_style->( 1, first { defined } @{ $h[ $line + 1 ] }[ $first .. $last ] ) : undef ),
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 2 branches
BranchTrueFalseTotal
$last == $columns - 1 ? : 17 19 36
$top_drawn ? : 15 21 36
211 );
212 36 my %corners;
213 36 ▶ $corners{top_left} = $corner->( $line, $first ) if $sides{top} && $sides{left};
Branch: 1 branch
BranchTrueFalseTotal
if $sides{"top"} and $sides{"left"} 15 21 36
Condition66%2/3
$sides{"top"} and $sides{"left"}
!ll&&!rl&&r
21015
MC/DC50%1/2
$sides{"top"} and $sides{"left"}
$sides{"top"} $sides{"left"}
Truth table66%2/3
A and B
A= $sides{"top"}B= $sides{"left"}
ABresult
0X0
100
111
214 36 ▶ $corners{top_right} = $corner->( $line, $columns ) if $sides{top} && $sides{right};
Branch: 1 branch
BranchTrueFalseTotal
if $sides{"top"} and $sides{"right"} 8 28 36
Condition100%3/3
$sides{"top"} and $sides{"right"}
!ll&&!rl&&r
2178
MC/DC100%2/2
$sides{"top"} and $sides{"right"}
$sides{"top"} $sides{"right"}
Truth table100%3/3
A and B
A= $sides{"top"}B= $sides{"right"}
ABresult
0X0
100
111
215 36 ▶ $corners{bottom_left} = $corner->( $line + 1, $first ) if $sides{bottom} && $sides{left};
Branch: 1 branch
BranchTrueFalseTotal
if $sides{"bottom"} and $sides{"left"} 15 21 36
Condition66%2/3
$sides{"bottom"} and $sides{"left"}
!ll&&!rl&&r
21015
MC/DC50%1/2
$sides{"bottom"} and $sides{"left"}
$sides{"bottom"} $sides{"left"}
Truth table66%2/3
A and B
A= $sides{"bottom"}B= $sides{"left"}
ABresult
0X0
100
111
216 36 ▶ $corners{bottom_right} = $corner->( $line + 1, $columns ) if $sides{bottom} && $sides{right};
Branch: 1 branch
BranchTrueFalseTotal
if $sides{"bottom"} and $sides{"right"} 8 28 36
Condition100%3/3
$sides{"bottom"} and $sides{"right"}
!ll&&!rl&&r
2178
MC/DC100%2/2
$sides{"bottom"} and $sides{"right"}
$sides{"bottom"} $sides{"right"}
Truth table100%3/3
A and B
A= $sides{"bottom"}B= $sides{"right"}
ABresult
0X0
100
111
217 36 delete @corners{ grep { !defined $corners{$_} } keys %corners };
218 36 my %on_frame = (
219 left => $first == 0,
220 right => $last == $columns - 1,
221 top => $line == 0,
222 bottom => $line == $last_line,
223 );
224 36 ▶ my @outer = grep { defined $sides{$_} && $on_frame{$_} && _drawn_outside( $sides{$_}, $_ ) } qw(left right top bottom);
Condition100%6/6
defined $sides{$_} && $on_frame{$_} && _drawn_outside($sides{$_}, $_)
!ll&&!rl&&r
100836
defined $sides{$_} and $on_frame{$_}
!ll&&!rl&&r
752544
MC/DC100%3/3
defined $sides{$_} && $on_frame{$_} && _drawn_outside($sides{$_}, $_)
defined $sides{$_} $on_frame{$_} _drawn_outside($sides{$_}, $_)
Truth table100%4/4
A and B && C
A= defined $sides{$_}B= $on_frame{$_}C= _drawn_outside($sides{$_}, $_)
ABCresult
0XX0
10X0
1100
1111
225 36 push @cells, { sides => { map { $_ => $sides{$_} } grep { defined $sides{$_} } keys %sides }, corners => \%corners, outer => \@outer };
226 }
227 17 push @result, \@cells;
228 }
229 7 return \@result;
230 }
231  
232 1 1;
233  
234 __END__
« blib/lib/Term/Fabulous/Chart/Format.pm ↑ Summary blib/lib/Term/Fabulous/Widget/Table/Frame.pm »