blib/lib/Acme/DotDotGone.pm

filter: Statementstmt 51.1% 22 / 43 Branchbran 38.8% 7 / 18 Conditioncond 11.1% 1 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 37.5% 6 / 16 Podpod n/a totaltotal 40.0% 36 / 90 CC 12 SCAR 31.6
CC
12
Cov
43%
import
50.8
__ANON__
2.0
__ANON__
2.0
CRAP 23.5
↑ Summary
1 package Acme::DotDotGone;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.02';
8  
9 1 our %dots;
10 BEGIN {
11 %dots = (
12 toDots => sub {
13 0 ▶ join ' ', map { $dots{$_}() } split '', unpack "b*", shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 },
15 fromDots => sub {
16 0 ▶ pack "b*", join '', map { $dots{$_}() } split ' ', shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 },
18 0 ▶ '.' => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 0 ▶ '..' => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 ▶ 0 => sub { '.' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 ▶ 1 => sub { '..' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 ▶ stderr => sub { print @_ }
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 1 ▶ );
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 close STDERR; # *\o/*
25 }
26  
27 sub import {
28 1 ▶ open FH, "<$0" or print "Cannot read '$0'\n" and exit;
Subroutine import: called CC=12 SCAR=39.3
Branch: 1 branch
BranchTrueFalseTotal
open FH, "<$0" or print "Cannot read '$0'\n" and exit 0 1 1
Condition25%1/4
open(FH, "<$0") || print("Cannot read '$0'\n") && exit
l!l
10
print "Cannot read '$0'\n" and exit
!ll
00
MC/DC0%0/2
open(FH, "<$0") || print("Cannot read '$0'\n") && exit
open(FH, "<$0") print "Cannot read '$0'\n"
Truth table33%1/3
A || B
A= open(FH, "<$0")B= print "Cannot read '$0'\n"
ABresult
1X1
011
000
29  
30 1 ▶ my $reg = $_[1]
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 1 1
31 ? qr/(.*)\1^\s*use\s+Acme::DotDotGone\s+($_[1]);\n/
32 : qr/.*^\s*use\s+Acme::DotDotGone;\n/;
33  
34 1 ($_[2] = (join '', <FH>)) =~ s/$reg//sm;
35 1 ▶ $_[2] = $1 . $_[2] if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 0 1 1
36  
37 1 close FH;
38  
39 ($_[2], $_[3], $_[4]) = (($2)
40 ? ($2 eq 'dot')
41 ? sub {
42 0 ▶ $_[1] = $dots{toDots}($_[0]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
43 0 $_[0], $_[1], $_[1];
44 }
45 : sub {
46 0 ▶ $_[1] = $dots{fromDots}($_[0]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 $_[1], $_[0], $_[1];
48 }
49 : ($_[2] =~ m/[a-zA-Z]/)
50 ? sub {
51 undef
52 1 ▶ }
Subroutine __ANON__: called CC=1 SCAR=0.0
53 : sub {
54 0 ▶ $_[1] = $dots{fromDots}($_[0]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 $_[1], $_[0];
56 }
57 1 ▶ )->($_[2]);
Branch: 3 branches
BranchTrueFalseTotal
$2 ? : 0 1 1
$2 eq 'dot' ? : 0 0 0
$_[2] =~ /[a-zA-Z]/ ? : 1 0 1
58  
59 1 ▶ if ($_[4]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[4]) 0 1 1
60 0 ▶ open FH, ">$0" or print "Cannot encode. '$0'\n" and exit;
Branch: 1 branch
BranchTrueFalseTotal
open FH, ">$0" or print "Cannot encode. '$0'\n" and exit 0 0 0
Condition0%0/5
open(FH, ">$0") || print("Cannot encode. '$0'\n") && exit
l!l&&r!l&&!r
000
print "Cannot encode. '$0'\n" and exit
!ll
00
MC/DC0%0/2
open(FH, ">$0") || print("Cannot encode. '$0'\n") && exit
open(FH, ">$0") print "Cannot encode. '$0'\n"
Truth table0%0/3
A || B
A= open(FH, ">$0")B= print "Cannot encode. '$0'\n"
ABresult
1X1
011
000
61 0 print FH "use Acme::DotDotGone;\n";
62 0 print FH $_[4];
63 0 close FH;
64 }
65  
66 1 ▶ do { eval "$_[2]"; $dots{stderr}($@); } if $_[2];
Branch: 1 branch
BranchTrueFalseTotal
if ($_[2]) 0 1 1
67 }
68  
69 1 1;
70  
71 __END__
↑ Summary