lib/FindApp/Utils/Syntax.pm

filter: Statementstmt 91.4% 43 / 47 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 100% 3 / 3 totaltotal 86.9% 60 / 69 CC 5 SCAR 8.1
CC
5
Cov
87%
function
5.1
case_fallthrough
2.0
case
1.1
CRAP 2.3
« lib/FindApp/Git.pm ↑ Summary lib/FindApp/Object/State.pm »
1 package FindApp::Utils::Syntax;
2  
3 6 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Sub::Name qw(subname);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶use FindApp::Utils::Assert qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use FindApp::Utils::Foreign qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #################################################################
13  
14 sub case ( & ) ;
15 sub case_fallthrough ( & ) ;
16 sub function ( $$ ) ;
17  
18 #################################################################
19  
20 6 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 6 our $VERSION = v1.0;
22 6 our @EXPORT_OK = qw(
23 case
24 case_fallthrough
25 function
26 );
27 6 our %EXPORT_TAGS = (
28 all => \@EXPORT_OK,
29 );
30  
31 #################################################################
32  
33 sub function($$) {
34 654 ▶ my($name, $code) = @_;
Subroutine function: called CC=5 SCAR=16.2
Pod documented
35 654 good_args(@_ == 2);
36 654 ▶ reftype($code) eq "CODE" || panic "wrong code type $code";
Branch: 1 branch
BranchTrueFalseTotal
&reftype($code) eq "CODE" or panic("wrong code type $code") 0 654 654
37  
38 654 for ($name) {
39 654 ▶ /^\w+(::\w+)*$/ || panic "bad function name $name";
Branch: 1 branch
BranchTrueFalseTotal
/^\w+(::\w+)*$/ or panic("bad function name $name") 0 654 654
40 654 ▶ s/^/caller() . "::"/e
Branch: 1 branch
BranchTrueFalseTotal
unless /::/ 654 0 654
41 unless /::/;
42 }
43  
44 ##print "$name\n";
45  
46 6 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
47 6 ▶ no warnings "redefine";
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 654 subname( $name => $code);
50 654 *$name = $code;
51 654 return \&$name;
52 }
53  
54 sub case(&) {
55 0 ▶ &case_fallthrough;
Subroutine case: not called CC=1 SCAR=0.6
Pod documented
56 6 ▶ no warnings "exiting";
Subroutine BEGIN: called CC=1 SCAR=0.0
57 0 next SWITCH;
58 }
59  
60 sub case_fallthrough(&) {
61 0 ▶ my($case) = @_;
Subroutine case_fallthrough: not called CC=1 SCAR=6.9
Pod documented
62 0 &$case;
63 }
64  
65 6 1;
66  
67 =encoding utf8
68  
69 =head1 NAME
70  
71 FindApp::Utils::Syntax - FIXME
72  
73 =head1 SYNOPSIS
74  
75 use FindApp::Utils::Syntax;
76  
77 =head1 DESCRIPTION
78  
79 =head2 Public Methods
80  
81 =over
82  
83 =item FIXME
84  
85 =back
86  
87 =head2 Exports
88  
89 =over
90  
91 =item case
92  
93 =item case_fallthrough
94  
95 =item function
96  
97 =item FIXME
98  
99 =back
100  
101 =head1 EXAMPLES
102  
103 =head1 ENVIRONMENT
104  
105 =head1 SEE ALSO
106  
107 =over
108  
109 =item L<FindApp>
110  
111 =back
112  
113 =head1 CAVEATS AND PROVISOS
114  
115 =head1 BUGS AND LIMITATIONS
116  
117 =head1 HISTORY
118  
119 =head1 AUTHOR
120  
121 Tom Christiansen << <tchrist@perl.com> >>
122  
123 =head1 LICENCE AND COPYRIGHT
124  
125 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
126 All Rights Reserved.
127  
128 This module is free software; you can redistribute it and/or
129 modify it under the same terms as Perl itself. See L<perlartistic>.
130  
131 =cut
132  
« lib/FindApp/Git.pm ↑ Summary lib/FindApp/Object/State.pm »