Carp/REPL.pm

filter: Statementstmt 70.3% 38 / 54 Branchbran 50.0% 9 / 18 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 59.5% 56 / 94 CC 13 SCAR 22.8
CC
13
Cov
60%
import
17.6
__ANON__
6.0
repl
5.7
CRAP 9.7
« Devel/REPL/Plugin/Carp/REPL.pm ↑ Summary
1 package Carp::REPL;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use 5.006000;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '0.18';
7  
8 4 our $noprofile = 0;
9 4 our $bottom_frame = 0;
10  
11 4 ▶sub import {
Subroutine import: called CC=8 SCAR=28.7
12 4 my $nodie = grep { $_ eq 'nodie' } @_;
13 4 my $warn = grep { $_ eq 'warn' } @_;
14 4 my $test = grep { $_ eq 'test' } @_;
15 4 $noprofile = grep { $_ eq 'noprofile'} @_;
16 4 my $repl = grep { $_ eq 'repl' } @_;
17  
18 4 ▶ if ($repl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($repl) 0 4 4
19  
20 0 require Sub::Exporter;
21 0 my $import_repl = Sub::Exporter::build_exporter(
22 {
23 exports => ['repl'],
24 into_level => 1,
25 }
26 );
27  
28 # get option of 'repl'
29 0 my $seen;
30 0 ▶ my ($maybe_option) = grep { $seen || $_ eq 'repl' && $seen++ } @_;
Condition0%0/6
$seen || $_ eq 'repl' && $seen++
l!l&&r!l&&!r
000
$_ eq "repl" and $seen++
!ll&&!rl&&r
000
MC/DC0%0/3
$seen || $_ eq 'repl' && $seen++
$seen $_ eq "repl" $seen++
Truth table0%0/4
A || B and C
A= $seenB= $_ eq "repl"C= $seen++
ABCresult
1XX1
0111
00X0
0100
31  
32 # now do the real 'repl' import
33 0 ▶ $import_repl->( __PACKAGE__, 'repl',
Branch: 1 branch
BranchTrueFalseTotal
ref $maybe_option ? : 0 0 0
34 ref $maybe_option ? $maybe_option : ()
35 );
36 }
37
38 4 ▶ $SIG{__DIE__} = \&repl unless $nodie;
Branch: 1 branch
BranchTrueFalseTotal
unless $nodie 3 1 4
39 4 ▶ $SIG{__WARN__} = \&repl if $warn;
Branch: 1 branch
BranchTrueFalseTotal
if $warn 1 3 4
40  
41 4 ▶ if ($test) {
Branch: 1 branch
BranchTrueFalseTotal
if ($test) 0 4 4
42 0 require Test::Builder;
43 0 my $ok = \&Test::Builder::ok;
44  
45 4 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
46 0 ▶ *Test::Builder::ok = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
47 0 local $Test::Builder::Level = $Test::Builder::Level + 1;
48 0 my $passed = $ok->(@_);
49 0 local $bottom_frame = $Test::Builder::Level;
50 0 ▶ repl("Test failure") if !$passed;
Branch: 1 branch
BranchTrueFalseTotal
unless $passed 0 0 0
51 0 return $passed;
52 0 };
53 }
54 }
55  
56 2 ▶sub repl {
Subroutine repl: called CC=5 SCAR=17.4
Pod documented
57 2 ▶ my $quiet = @_ && !defined($_[0]);
Condition66%2/3
@_ && !defined($_[0])
!ll&&!rl&&r
110
MC/DC0%0/2
@_ && !defined($_[0])
@_ !defined($_[0])
Truth table66%2/3
A && not(B)
A= @_B= !defined($_[0])
ABresult
0X0
100
111
58  
59 2 ▶ warn @_, "\n" unless $quiet; # tell the user what blew up
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 2 0 2
60  
61 2 require Devel::REPL::Script;
62  
63 2 my ($runner, $repl);
64 2 ▶ if ($noprofile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Carp::REPL::noprofile) { } 2 0 2
65 2 $repl = $runner = Devel::REPL->new;
66 }
67 else {
68 0 $runner = Devel::REPL::Script->new;
69 0 $repl = $runner->_repl;
70 }
71  
72 2 $repl->load_plugin('Carp::REPL');
73  
74 2 ▶ warn $repl->stacktrace unless $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 2 0 2
75  
76 2 $runner->run;
77 }
78  
79 4 1;
80  
81 __END__
« Devel/REPL/Plugin/Carp/REPL.pm ↑ Summary