blib/lib/Long/Jump.pm

filter: Statementstmt 97.6% 41 / 42 Branchbran 92.8% 13 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 97.2% 70 / 72 CC 9 SCAR 12.2
CC
9
Cov
97%
setjump
6.0
longjump
3.0
havejump
2.0
CRAP 3.4
↑ Summary
1 package Long::Jump;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '0.000005';
6  
7 2 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Importer Importer => 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our @EXPORT_OK = qw/setjump longjump havejump/;
11  
12 2 my (%STACK, $SEEK, $OUT);
13  
14 15 ▶sub havejump { $STACK{$_[-1]} ? 1 : 0 }
Subroutine havejump: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$STACK{$_[-1]} ? : 7 8 15
15  
16 20 ▶sub setjump {
Subroutine setjump: called CC=6 SCAR=17.9
Pod documented
17 20 my ($name, $code, @args) = @_;
18  
19 20 ▶ croak "You must name your jump point" unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 1 19 20
20 19 ▶ croak "You must provide a subroutine as a second argument" unless $code && ref($code) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless $code and ref $code eq "CODE" 2 17 19
Condition100%3/3
$code and ref $code eq "CODE"
!ll&&!rl&&r
1117
MC/DC100%2/2
$code and ref $code eq "CODE"
$code ref $code eq "CODE"
Truth table100%3/3
A and B
A= $codeB= ref $code eq "CODE"
ABresult
0X0
100
111
21  
22 17 ▶ croak "There is already a jump point named '$name'" if exists $STACK{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $STACK{$name} 1 16 17
23  
24 16 local $STACK{$name} = 1;
25  
26 LONG_JUMP_SET: {
27 16 $code->(@args);
28 6 return undef;
29 }
30  
31 9 ▶ longjump($SEEK, @$OUT) if $name ne $SEEK;
Branch: 1 branch
BranchTrueFalseTotal
if $name ne $SEEK 3 6 9
32  
33 6 my $out = $OUT;
34 6 $OUT = undef;
35 6 return $out;
36 }
37  
38 11 ▶sub longjump {
Subroutine longjump: called CC=3 SCAR=11.0
Pod documented
39 11 $SEEK = shift;
40  
41 11 ▶ croak "No such jump point: '$SEEK'" unless $STACK{$SEEK};
Branch: 1 branch
BranchTrueFalseTotal
unless $STACK{$SEEK} 2 9 11
42  
43 10 $OUT = [@_];
44  
45 0 ▶ my $ok = eval { no warnings 'exiting'; last LONG_JUMP_SET; 1 };
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 my $err = $@;
47  
48 1 my $msg = "longjump('$SEEK') failed";
49 1 ▶ $msg .= ", error: $err" unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 1 0 1
50  
51 1 croak $msg;
52 }
53  
54 2 1;
55  
56 __END__
↑ Summary