lib/TUI/Views/Palette.pm

filter: Statementstmt 79.6% 47 / 59 Branchbran 50.0% 6 / 12 Conditioncond 62.5% 5 / 8 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 75.0% 9 / 12 Podpod 83.3% 5 / 6 totaltotal 72.5% 74 / 102 CC 11 SCAR 13.6
CC
11
Cov
73%
new
7.1
from
6.0
at
3.2
CRAP 3.9
« lib/TUI/Views/CommandSet.pm ↑ Summary lib/TUI/Objects/NSSortedCollection.pm »
1 package TUI::Views::Palette;
2 # ABSTRACT: A class for managing color palettes
3
4 95 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 95 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 95 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 95 our $VERSION = '2.000002';
9 95 $VERSION =~ tr/_//d;
10 95 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 95 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 95 our @EXPORT = qw(
14 TPalette
15 new_TPalette
16 );
17
18 95 require bytes;
19 95 ▶use TUI::toolkit qw( assert signature );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 95 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 :types
22 95 );
23
24 sub TPalette() { __PACKAGE__ }
25 0 ▶sub new_TPalette { __PACKAGE__->from(@_) }
Subroutine new_TPalette: not called CC=1 SCAR=6.9
Pod documented
26
27 5 ▶sub new { # $obj (%args)
Subroutine new: called CC=7 SCAR=19.6
Pod documented
28 5 state $sig = signature(
29 method => 1,
30 named => [
31 data => Str, { optional => 1 },
32 size => PositiveOrZeroInt, { optional => 1 },
33 copy_from => ArrayLike, { optional => 1 },
34 ],
35 );
36 5 my ( $class, $args ) = $sig->( @_ );
37 5 my @data = ( 0 );
38 5 ▶ if ( defined $args->{data} && defined $args->{size} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $args->{'data'} and defined $args->{'size'}) { } 4 1 5
elsif (defined $args->{'copy_from'}) { } 1 0 1
Condition66%2/3
defined $args->{"data"} and defined $args->{"size"}
!ll&&!rl&&r
104
MC/DC50%1/2
defined $args->{"data"} and defined $args->{"size"}
defined $args->{"data"} defined $args->{"size"}
Truth table66%2/3
A and B
A= defined $args->{"data"}B= defined $args->{"size"}
ABresult
0X0
100
111
39 4 my $len = $args->{size};
40 4 $data[0] = $len;
41 4 @data[ 1 .. $len ] = unpack "(C)$len", $args->{data};
42 4 ▶ $_ //= 0 for @data;
Condition100%2/2
$_ //= 0
l!l
161
MC/DC100%1/1
$_ //= 0
$_
Truth table100%2/2
A
A= $_
Aresult
11
00
43 }
44 elsif ( defined $args->{copy_from} ) {
45 1 my $tp = $args->{copy_from};
46 1 ▶ assert ( $tp->[0] == @$tp - 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless $tp->[0] == @$tp - 1 0 1 1
47 1 @data = @$tp;
48 }
49 5 return bless \@data, $class;
50 }
51
52 0 ▶sub from { # $obj ($tp|$d, $len)
Subroutine from: not called CC=2 SCAR=17.9
Pod undocumented
53 0 ▶ if ( @_ > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) { } 0 0 0
54 0 state $sig = signature(
55 method => 1,
56 pos => [Str, PositiveOrZeroInt],
57 );
58 0 my ( $class, $d, $len ) = $sig->( @_ );
59 0 return $class->new( data => $d, size => $len );
60 }
61 else {
62 0 state $sig = signature(
63 method => 1,
64 pos => [ArrayLike],
65 );
66 0 my ( $class, $tp ) = $sig->( @_ );
67 0 return $class->new( copy_from => $tp );
68 }
69 }
70
71 0 ▶sub clone { # $clone ($self)
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
72 0 state $sig = signature(
73 method => 1,
74 pos => [],
75 );
76 0 my ( $self ) = $sig->( @_ );
77 0 my @data = @$self;
78 0 return bless \@data, ref $self;
79 }
80
81 1 ▶sub assign { # $self ($tp)
Subroutine assign: called CC=2 SCAR=7.0
Pod documented
82 1 state $sig = signature(
83 method => 1,
84 pos => [ArrayLike],
85 );
86 1 my ( $self, $tp ) = $sig->( @_ );
87 1 ▶ assert ( $tp->[0] == @$tp - 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless $tp->[0] == @$tp - 1 0 1 1
88 1 @$self = @$tp;
89 1 return $self;
90 }
91
92 20 ▶sub at { # $entry ($index)
Subroutine at: called CC=3 SCAR=11.8
Pod documented
93 20 state $sig = signature(
94 method => 1,
95 pos => [Int],
96 );
97 20 my ( $self, $index ) = $sig->( @_ );
98 20 ▶ assert ( $index >= 0 && $index <= @$self );
Branch: 1 branch
BranchTrueFalseTotal
unless $index >= 0 and $index <= @$self 0 20 20
Condition33%1/3
$index >= 0 and $index <= @$self
!ll&&!rl&&r
0020
MC/DC0%0/2
$index >= 0 and $index <= @$self
$index >= 0 $index <= @$self
Truth table33%1/3
A and B
A= $index >= 0B= $index <= @$self
ABresult
0X0
100
111
99 20 return $self->[$index];
100 }
101
102 95 1
103
104 __END__
« lib/TUI/Views/CommandSet.pm ↑ Summary lib/TUI/Objects/NSSortedCollection.pm »