StateML/Utils.pm

filter: Statementstmt 100% 15 / 15 Branchbran 62.5% 5 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 91.1% 31 / 34 CC 6 SCAR 11.4
CC
6
Cov
88%
as_str
4.2
empty
3.0
BEGIN
1.0
CRAP 3.1
« StateML/State.pm ↑ Summary StateML/Class.pm »
1 package StateML::Utils;
2  
3 4 $VERSION = 0.000_1;
4  
5 =head1 NAME
6  
7 StateML::Utils - Some handy utility functions
8  
9 =head1 SYNOPSIS
10  
11 use StateML::Utils qw( empty as_string );
12  
13 =head1 DESCRIPTION
14  
15 Some handy uti.... you get the idea.
16  
17 =cut
18  
19 4 @EXPORT_OK = qw( empty as_str );
20 4 %EXPORT_TAGS = ( all => \@EXPORT_OK );
21 4 @ISA = qw( Exporter );
22 4 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =head1 FUNCTIONS
27  
28 =over
29  
30 =cut
31  
32 =item empty
33  
34 Returns TRUE if the single arg is not defined or of zero length. "0" is
35 not empty. This does not have a prototype like defined() or length() because
36 the precedance can't be set properly. Tests $_ if no parameters are passed.
37  
38 =cut
39  
40 5 ▶sub empty {
Subroutine empty: called CC=3 SCAR=11.1
Pod documented
41 5 ▶ local $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 5 5
42 5 ▶ return ! ( defined && length );
Condition100%3/3
defined $_ && length $_
!ll&&!rl&&r
113
MC/DC100%2/2
defined $_ && length $_
defined $_ length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
43 }
44  
45 =item as_str
46  
47 warn as_str "hey!", undef.
48  
49 Converts the list of parameters to a string, quoting plain scalars
50 if need be and reporting them as undef if they are undefined. May
51 handle other situations/structures in the future.
52  
53 Does an implicit join( "", ... ) in scalar context.
54  
55 =cut
56  
57 2 ▶sub as_str {
Subroutine as_str: called CC=4 SCAR=14.5
Pod documented
58 2 ▶ my @out = map
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 2 2
defined $_ ? : 1 1 2
59 ref $_ ? ref $_ : defined $_ ? "'$_'" : "undef",
60 @_;
61  
62 2 ▶ return wantarray ? @out : join "", @out;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
63 }
64  
65 =back
66  
67 =head1 LIMITATIONS
68  
69 =head1 COPYRIGHT
70  
71 Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved
72  
73 =head1 LICENSE
74  
75 You may use this module under the terms of the BSD, Artistic, or GPL licenses,
76 any version.
77  
78 =head1 AUTHOR
79  
80 Barrie Slaymaker <barries@slaysys.com>
81  
82 =cut
83  
84 4 1;
« StateML/State.pm ↑ Summary StateML/Class.pm »