lib/FP/Char.pm

filter: Statementstmt 83.3% 20 / 24 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 3 totaltotal 59.0% 26 / 44 CC 4 SCAR 20.8
CC
4
Cov
65%
is_char
20.0
char_is_whitespace
2.0
BEGIN
1.0
CRAP 8.0
« lib/FP/PureHash.pm ↑ Summary lib/FP/HashSet.pm »
1 #
2 # Copyright (c) 2013-2020 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 FP::Char - functions to handle individual characters
13  
14 =head1 SYNOPSIS
15  
16 =head1 DESCRIPTION
17  
18 Perl doesn't have a distinct data type for individual characters, any
19 string containing 1 character is considered to be a char by
20 FP::Char. (Creating references and blessing them for the sake of
21 type safety seemed excessive.)
22  
23  
24 =head1 NOTE
25  
26 This is alpha software! Read the status section in the package README
27 or on the L<website|http://functional-perl.org/>.
28  
29 =cut
30  
31 package FP::Char;
32 60 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 60 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 60 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
35 60 ▶use Exporter "import";
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 60 our @EXPORT = qw();
38 60 our @EXPORT_OK = qw(is_char char_is_whitespace char_is_alphanumeric);
39 60 our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
40  
41 60 ▶use FP::Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 0 ▶sub is_char {
Subroutine is_char: not called CC=4 SCAR=30.0
Pod undocumented
44 0 ▶ @_ == 1 or fp_croak_arity 1;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or fp_croak_arity(1) 0 0 0
45 0 my ($v) = @_;
46 0 ▶ defined $v and not(ref $v) and length($v) == 1
Branch: 1 branch
BranchTrueFalseTotal
defined $v and not ref $v and length $v == 1 0 0 0
Condition0%0/3
defined $v and not ref $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and not ref $v
defined $v not ref $v
Truth table0%0/3
A and not(B)
A= defined $vB= not ref $v
ABresult
0X0
100
111
47 }
48  
49 0 ▶sub char_is_whitespace {
Subroutine char_is_whitespace: not called CC=1 SCAR=6.9
Pod undocumented
50  
51 # not including non-breaking space, OK?
52 0 $_[0] =~ /^[ \r\n\t\f]$/s
53 }
54  
55 31 ▶sub char_is_alphanumeric {
Subroutine char_is_alphanumeric: called CC=1 SCAR=0.0
Pod undocumented
56 31 $_[0] =~ /^[a-zA-Z0-9_]$/s
57 }
58  
59 60 1
60  
« lib/FP/PureHash.pm ↑ Summary lib/FP/HashSet.pm »