blib/lib/Acme/Undead.pm

filter: Statementstmt 64.1% 34 / 53 Branchbran 25.0% 3 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 69.2% 9 / 13 Podpod n/a totaltotal 55.4% 46 / 83 CC 10 SCAR 21.0
CC
10
Cov
54%
END
22.9
_bless
12.0
_sleep
6.0
CRAP 8.2
↑ Summary
1 package Acme::Undead;
2 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = "0.03";
7  
8 =encoding utf-8
9  
10 =head1 NAME
11  
12 Acme::Undead - The Undead is not die!
13  
14 =head1 SYNOPSIS
15  
16 use Acme::Undead;
17 die('undead is not die');
18 print 'Hell world';
19  
20 #Hell world
21  
22 no Acme::Undead;
23  
24 die() #died;
25  
26 =head1 DESCRIPTION
27  
28 Acme::Undead is export routines, die(), bless() and sleep().
29 Use Acme::Undead when dont die at die(), die at bless() and not sleep at sleep().
30  
31 =head1 OVERRIDE METHODS
32  
33 =head2 die
34  
35 undead is not die!
36  
37 =head2 sleep
38  
39 undead is not sleeping
40  
41 =head2 bless
42  
43 the god bless clean undead auras.
44  
45 =cut
46  
47 2 our @EXPORT = qw/die sleep bless/;
48 2 our $IS_UNDEAD = 0;
49  
50 2 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
51 2 my $class = shift;
52 2 my $caller = shift;
53 2 $^H{acme_undead} = 1;
54 2 $IS_UNDEAD = 1;
55 {
56 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 for my $func (@EXPORT) {
59 6 my $local_func = "_" . $func;
60 6 *{"${caller}::$func"} = *{"Acme::Undead::$local_func"};
61 }
62 }
63 }
64  
65 2 ▶sub unimport {
Subroutine unimport: called CC=1 SCAR=0.0
66 2 $^H{acme_undead} = 0;
67 2 $IS_UNDEAD = 0;
68 }
69  
70 2 ▶sub _die {
Subroutine _die: called CC=2 SCAR=6.9
71 2 my $class = shift;
72 2 my $hinthash = (caller(0))[10];
73 2 ▶ return $hinthash->{acme_undead} ? undef : die(shift);
Branch: 1 branch
BranchTrueFalseTotal
$hinthash->{'acme_undead'} ? : 1 1 2
74 }
75  
76 0 ▶sub _sleep {
Subroutine _sleep: not called CC=2 SCAR=17.9
77 0 my $hinthash = (caller(0))[10];
78 0 ▶ return $hinthash->{acme_undead} ? undef : sleep(shift);
Branch: 1 branch
BranchTrueFalseTotal
$hinthash->{'acme_undead'} ? : 0 0 0
79 }
80  
81 0 ▶sub _bless {
Subroutine _bless: not called CC=3 SCAR=24.8
82 0 my $hinthash = (caller(0))[10];
83 0 ▶ return $hinthash->{acme_undead} ? die('blessed') : do {
Branch: 1 branch
BranchTrueFalseTotal
$hinthash->{'acme_undead'} ? : 0 0 0
84 0 my $arg = shift;
85 0 ▶ my $pkg = shift || (caller(0))[0];
Condition0%0/3
shift() || (caller 0)[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || (caller 0)[0]
shift() (caller 0)[0]
Truth table0%0/3
A || B
A= shift()B= (caller 0)[0]
ABresult
1X1
011
000
86 0 bless($arg, $pkg);
87 }
88 }
89  
90 2 ▶sub END {
Subroutine END: called CC=5 SCAR=31.3
91 2 ▶ return unless $IS_UNDEAD;
Branch: 1 branch
BranchTrueFalseTotal
unless $Acme::Undead::IS_UNDEAD 2 0 2
92 0 my @signals = keys %SIG;
93 0 my $pid = fork();
94 0 ▶ if ($pid){
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 0 0 0
95 0 local %SIG;
96 0 for my $sig (@signals){
97 0 ▶ $SIG{$sig} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 0 warn 'undead is die';
99 0 };
100 }
101 0 ▶ $SIG{USR1} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 $IS_UNDEAD = 0;
103 0 };
104 0 ▶ while($IS_UNDEAD){ sleep 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($Acme::Undead::IS_UNDEAD) 0 0 0
105 }
106 else {
107 0 exit;
108 }
109 }
110  
111 2 1;
112 __END__
↑ Summary