| 1 | package Unexpected::Functions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use parent 'Exporter::Tiny'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Package::Stash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Scalar::Util qw( blessed reftype ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Sub::Install qw( install_sub ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | our @EXPORT_OK = qw( catch_class exception has_exception | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | inflate_message inflate_placeholders is_class_loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | is_one_of_us parse_arg_list throw throw_on_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | my $Exception_Class = 'Unexpected'; my $Should_Quote = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Private functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 10 | ▶ | my $_catch = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 10 | my $block = shift; return ((bless \$block, 'Try::Tiny::Catch'), @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | my $_clone_one_of_us = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | return $_[ 1 ] ? { %{ $_[ 0 ] }, %{ $_[ 1 ] } } : { error => $_[ 0 ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | my $_dereference_code = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | my ($code, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | $args[ 0 ] and ref $args[ 0 ] eq 'ARRAY' and unshift @args, 'args'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args[0] and ref $args[0] eq "ARRAY"
MC/DC100%2/2
$args[0] and ref $args[0] eq "ARRAY"
$args[0]
ref $args[0] eq "ARRAY"
Truth table100%3/3
A and B
A= $args[0]B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | return { class => $code->(), @args }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | my $_exception_class_cache = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 28 | ▶ | my $_exception_class = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 28 | my $caller = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | exists $_exception_class_cache->{ $caller } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | and defined $_exception_class_cache->{ $caller } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 28 | ▶ | and return $_exception_class_cache->{ $caller }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $_exception_class_cache->{$caller} and defined $_exception_class_cache->{$caller}
MC/DC50%1/2
exists $_exception_class_cache->{$caller} and defined $_exception_class_cache->{$caller}
exists $_exception_class_cache->{$caller}
defined $_exception_class_cache->{$caller}
Truth table66%2/3
A and B
A= exists $_exception_class_cache->{$caller}B= defined $_exception_class_cache->{$caller}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 18 | my $code = $caller->can( 'EXCEPTION_CLASS' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 18 | ▶ | my $class = $code ? $code->() : $Exception_Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 18 | return $_exception_class_cache->{ $caller } = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 13 | ▶ | my $_match_class = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | my ($e, $ref, $blessed, $does, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | ▶ | return !defined $key ? !defined $e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition50%3/6
$blessed and $e->can("instance_of")
$blessed and $e->$does($key)
MC/DC50%1/2
$blessed and $e->can("instance_of")
$blessed
$e->can("instance_of")
MC/DC0%0/2
$blessed and $e->$does($key)
$blessed
$e->$does($key)
Truth table66%2/3
A and B
A= $blessedB= $e->can("instance_of")
Truth table33%1/3
A and B
A= $blessedB= $e->$does($key)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | : $key eq '*' ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | : $key eq ':str' ? !$ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | : $key eq $ref ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | : $blessed && $e->can( 'instance_of' ) ? $e->instance_of( $key ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | : $blessed && $e->$does( $key ) ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 495 | ▶ | my $_quote_maybe = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 495 | ▶ | return $Should_Quote ? "'".$_[ 0 ]."'" : $_[ 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 11 | ▶ | my $_gen_checker = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 11 | my @prototable = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 10 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 10 | my $e = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 10 | my $ref = ref $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 10 | my $blessed = blessed $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 10 | ▶ | my $does = ($blessed && $e->can( 'DOES' )) || 'isa'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$blessed && $e->can('DOES') || 'isa'
$blessed and $e->can("DOES")
MC/DC50%1/2
$blessed && $e->can('DOES') || 'isa'
$blessed
$e->can("DOES")
Truth table66%2/3
A and B
A= $blessedB= $e->can("DOES")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 10 | my @table = @prototable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 10 | ▶ | while (my ($key, $value) = splice @table, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 13 | ▶ | $_match_class->( $e, $ref, $blessed, $does, $key ) and return $value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # Package methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 23 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 23 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 23 | ▶ | my $global_opts = { $_[ 0 ] && ref $_[ 0 ] eq 'HASH' ? %{+ shift } : () }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "HASH"
MC/DC100%2/2
$_[0] and ref $_[0] eq "HASH"
$_[0]
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 23 | my $ex_class = delete $global_opts->{exception_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # uncoverable condition false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 23 | ▶ | my $target = $global_opts->{into} //= caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/3
$global_opts->{"into"} //= caller
MC/DC100%0/2
$global_opts->{"into"} //= caller
$global_opts->{"into"}
caller
Truth table100%2/3
A //= B
A= $global_opts->{"into"}B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 23 | my @want = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 23 | my @args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 23 | ▶ | $ex_class or $ex_class = $_exception_class->( $target ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 23 | for my $sym (@want) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 29 | ▶ | if ($ex_class->can( 'is_exception' ) and $ex_class->is_exception( $sym )){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ex_class->can("is_exception") and $ex_class->is_exception($sym)
MC/DC100%2/2
$ex_class->can("is_exception") and $ex_class->is_exception($sym)
$ex_class->can("is_exception")
$ex_class->is_exception($sym)
Truth table100%3/3
A and B
A= $ex_class->can("is_exception")B= $ex_class->is_exception($sym)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | my $code = sub { sub { $sym } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | install_sub { as => $sym, code => $code, into => $target, }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 27 | else { push @args, $sym } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 23 | $class->SUPER::import( $global_opts, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | sub quote_bind_values { # Deprecated. Use third arg in inflate_placeholders defs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote_bind_values: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | defined $_[ 1 ] and $Should_Quote = !!$_[ 1 ]; return $Should_Quote; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Public functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 43 | ▶ | sub parse_arg_list (;@) { # Coerce a hash ref from whatever was passed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_arg_list: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 43 | ▶ | my $n = 0; $n++ while (defined $_[ $n ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | return ( $n == 0) ? {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | : (is_one_of_us( $_[ 0 ] )) ? $_clone_one_of_us->( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | : ( ref $_[ 0 ] eq 'CODE') ? $_dereference_code->( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 6 | ▶ | : ( ref $_[ 0 ] eq 'HASH') ? { %{ $_[ 0 ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | : ( $n == 1) ? { error => $_[ 0 ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | : ( ref $_[ 1 ] eq 'ARRAY') ? { error => (shift), args => @_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 43 | ▶ | : ( ref $_[ 1 ] eq 'HASH') ? { error => $_[ 0 ], %{ $_[ 1 ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | : ( $n % 2 == 1) ? { error => @_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | : { @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | ▶ | sub catch_class ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
catch_class: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 11 | ▶ | my $check = $_gen_checker->( @{+ shift }, '*' => sub { die $_[ 0 ] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 11 | ▶ | wantarray or croak 'Useless bare catch_class()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 10 | ▶ | return $_catch->( sub { ($check->( $_[ 0 ] ) || return)->( $_[ 0 ] ) }, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
&$check($_[0]) || (return)
MC/DC100%1/1
&$check($_[0]) || (return)
&$check($_[0])
Truth table100%2/2
A
A= &$check($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | sub exception (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exception: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | return $_exception_class->( caller )->caught( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | ▶ | sub has_exception ($;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_exception: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | my ($name, %args) = @_; my $exception_class = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | return $exception_class->add_exception( $name, \%args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 31 | ▶ | sub inflate_message ($;@) { # Expand positional parameters of the form [_<n>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 31 | return inflate_placeholders( [ '[?]', '[]' ], @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 46 | ▶ | sub inflate_placeholders ($;@) { # Sub visible strings for null and undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_placeholders: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 46 | my $defaults = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 46 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 507 | ▶ | my @vals = map { $defaults->[ 2 ] ? $_ : $_quote_maybe->( $_ ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # uncoverable condition false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 507 | ▶ | map { (length) ? $_ : $defaults->[ 1 ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 507 | ▶ | map { $_ // $defaults->[ 0 ] } @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_ // $defaults->[0]
MC/DC0%0/2
$_ // $defaults->[0]
$_
$defaults->[0]
Truth table66%2/3
A // B
A= $_B= $defaults->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 46 | map { $defaults->[ 0 ] } 0 .. 9; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 46 | $msg =~ s{ \[ _ (\d+) \] }{$vals[ $1 - 1 ]}gmx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 46 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 17 | ▶ | sub is_class_loaded ($) { # Lifted from Class::Load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_class_loaded: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 17 | my $class = shift; my $stash = Package::Stash->new( $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 17 | ▶ | if ($stash->has_symbol( '$VERSION' )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | my $version = ${ $stash->get_symbol( '$VERSION' ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | ▶ | if (defined $version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | ▶ | not ref $version and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # Sometimes $VERSION ends up as a reference to undef (weird) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | reftype $version eq 'SCALAR' and defined ${ $version } and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::reftype($version) eq "SCALAR" and defined ${$version;}
MC/DC100%2/2
builtin::reftype($version) eq "SCALAR" and defined ${$version;}
builtin::reftype($version) eq "SCALAR"
defined ${$version;}
Truth table100%3/3
A and B
A= builtin::reftype($version) eq "SCALAR"B= defined ${$version;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | blessed $version and return 1; # A version object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 14 | ▶ | $stash->has_symbol( '@ISA' ) and @{ $stash->get_symbol( '@ISA' ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$stash->has_symbol("\@ISA") and @{$stash->get_symbol("\@ISA");}
MC/DC100%2/2
$stash->has_symbol("\@ISA") and @{$stash->get_symbol("\@ISA");}
$stash->has_symbol("\@ISA")
@{$stash->get_symbol("\@ISA");}
Truth table100%3/3
A and B
A= $stash->has_symbol("\@ISA")B= @{$stash->get_symbol("\@ISA");}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # Check for any method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 12 | ▶ | return $stash->list_all_symbols( 'CODE' ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 71 | ▶ | sub is_one_of_us ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_one_of_us: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 71 | ▶ | return $_[ 0 ] && (blessed $_[ 0 ]) && $_[ 0 ]->isa( $Exception_Class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$_[0] && builtin::blessed($_[0]) && $_[0]->isa($Exception_Class)
$_[0] and builtin::blessed($_[0])
MC/DC100%3/3
$_[0] && builtin::blessed($_[0]) && $_[0]->isa($Exception_Class)
$_[0]
builtin::blessed($_[0])
$_[0]->isa($Exception_Class)
Truth table100%4/4
A and B && C
A= $_[0]B= builtin::blessed($_[0])C= $_[0]->isa($Exception_Class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | ▶ | sub throw (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | $_exception_class->( caller )->throw( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | sub throw_on_error (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw_on_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | return $_exception_class->( caller )->throw_on_error( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||