| 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
| |||||||||||||||||||||||||||||||||||
| 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++
$_ eq "repl" and $seen++
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++
| |||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | # now do the real 'repl' import | ||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $import_repl->( __PACKAGE__, 'repl', | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | ref $maybe_option ? $maybe_option : () | ||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | $SIG{__DIE__} = \&repl unless $nodie; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | $SIG{__WARN__} = \&repl if $warn; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | if ($test) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||
| 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])
MC/DC0%0/2
@_ && !defined($_[0])
@_
!defined($_[0])
Truth table66%2/3
A && not(B)
A= @_B= !defined($_[0])
| |||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | warn @_, "\n" unless $quiet; # tell the user what blew up | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 2 | require Devel::REPL::Script; | |||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | 2 | my ($runner, $repl); | |||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | if ($noprofile) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | 2 | $runner->run; | |||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | 4 | 1; | |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||||||||