lib/TUI/Dialogs/Util.pm

filter: Statementstmt 50.0% 23 / 46 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 66.6% 6 / 9 Podpod 100% 3 / 3 totaltotal 38.5% 32 / 83 CC 9 SCAR 24.8
CC
9
Cov
35%
prevWord
20.0
nextWord
20.0
hotKey
12.0
CRAP 11.9
« lib/TUI/ColorSel/ColorDisplay.pm ↑ Summary lib/TUI/ColorSel/ColorDialog.pm »
1 package TUI::Dialogs::Util;
2 # ABSTRACT: Various utility functions for dialogs
3
4 32 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 32 our $VERSION = '2.000002';
9 32 $VERSION =~ tr/_//d;
10 32 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 32 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14 32 our @EXPORT_OK = qw(
15 hotKey
16 prevWord
17 nextWord
18 );
19
20 32 our %EXPORT_TAGS = (
21 all => \@EXPORT_OK,
22 );
23
24 32 ▶use TUI::toolkit qw( signature );
Subroutine BEGIN: called CC=1 SCAR=0.0
25 32 ▶use TUI::toolkit::Types qw( Str Int );
Subroutine BEGIN: called CC=1 SCAR=0.0
26
27 0 ▶sub hotKey ($) { # $hotkey ($s)
Subroutine hotKey: not called CC=3 SCAR=24.8
Pod documented
28 0 state $sig = signature(
29 pos => [Str],
30 );
31 0 my ( $s ) = $sig->( @_ );
32
33 0 my $pos = index( $s, '~' );
34 0 ▶ if ( $pos != -1 && $pos + 1 < length( $s ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos != -1 and $pos + 1 < length $s) { } 0 0 0
Condition0%0/3
$pos != -1 and $pos + 1 < length $s
!ll&&!rl&&r
000
MC/DC0%0/2
$pos != -1 and $pos + 1 < length $s
$pos != -1 $pos + 1 < length $s
Truth table0%0/3
A and B
A= $pos != -1B= $pos + 1 < length $s
ABresult
0X0
100
111
35 0 return uc substr( $s, $pos + 1, 1 );
36 }
37 else {
38 0 return '';
39 }
40 }
41
42 0 ▶sub prevWord ($$) { # $index ($s, $pos)
Subroutine prevWord: not called CC=4 SCAR=30.0
Pod documented
43 0 state $sig = signature(
44 pos => [Str, Int],
45 );
46 0 my ( $s, $pos ) = $sig->( @_ );
47
48 0 ▶ for ( my $i = $pos - 1 ; $i >= 1 ; --$i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 1) 0 0 0
49 0 my $curr = substr( $s, $i, 1 );
50 0 my $prev = substr( $s, $i - 1, 1 );
51 0 ▶ if ( $curr ne ' ' && $prev eq ' ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($curr ne " " and $prev eq " ") 0 0 0
Condition0%0/3
$curr ne " " and $prev eq " "
!ll&&!rl&&r
000
MC/DC0%0/2
$curr ne " " and $prev eq " "
$curr ne " " $prev eq " "
Truth table0%0/3
A and B
A= $curr ne " "B= $prev eq " "
ABresult
0X0
100
111
52 0 return $i;
53 }
54 }
55 0 return 0;
56 }
57
58 0 ▶sub nextWord ($$) { # $index ($s, $pos)
Subroutine nextWord: not called CC=4 SCAR=30.0
Pod documented
59 0 state $sig = signature(
60 pos => [Str, Int],
61 );
62 0 my ( $s, $pos ) = $sig->( @_ );
63
64 0 my $len = length( $s );
65 0 ▶ for ( my $i = $pos ; $i < $len - 1 ; ++$i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len - 1) 0 0 0
66 0 my $curr = substr( $s, $i, 1 );
67 0 my $next = substr( $s, $i + 1, 1 );
68 0 ▶ if ( $curr eq ' ' && $next ne ' ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($curr eq " " and $next ne " ") 0 0 0
Condition0%0/3
$curr eq " " and $next ne " "
!ll&&!rl&&r
000
MC/DC0%0/2
$curr eq " " and $next ne " "
$curr eq " " $next ne " "
Truth table0%0/3
A and B
A= $curr eq " "B= $next ne " "
ABresult
0X0
100
111
69 0 return $i + 1;
70 }
71 }
72 0 return $len;
73 }
74
75 32 1
76
77 __END__
« lib/TUI/ColorSel/ColorDisplay.pm ↑ Summary lib/TUI/ColorSel/ColorDialog.pm »