| 1 | package Test2::Util::Ref; | ||||||||||||||||||||||||||||
| 2 | 177 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 177 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 177 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 177 | ▶ | use Scalar::Util qw/reftype blessed refaddr/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 177 | our @EXPORT_OK = qw/rtype render_ref/; | |||||||||||||||||||||||||||
| 10 | 177 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 23161 | ▶ | sub rtype { | ||||||||||||||||||||||||||
|
Subroutine
rtype: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 23161 | my ($thing) = @_; | |||||||||||||||||||||||||||
| 14 | 23161 | ▶ | return '' unless defined $thing; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 23159 | my $rf = ref $thing; | |||||||||||||||||||||||||||
| 17 | 23159 | my $rt = reftype $thing; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 23159 | ▶ | return '' unless $rf || $rt; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$rf or $rt
MC/DC50%1/2
$rf or $rt
$rf
$rt
Truth table66%2/3
A or B
A= $rfB= $rt
| |||||||||||||||||||||||||||||
| 20 | 5857 | ▶ | return 'REGEXP' if $rf =~ m/Regex/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 5585 | ▶ | return 'REGEXP' if $rt =~ m/Regex/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 5585 | ▶ | return $rt || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$rt || ''
MC/DC0%0/1
$rt || ''
$rt
Truth table50%1/2
A
A= $rt
| |||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 14999 | ▶ | sub render_ref { | ||||||||||||||||||||||||||
|
Subroutine
render_ref: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 14999 | my ($in) = @_; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 14999 | ▶ | return 'undef' unless defined($in); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 14692 | my $type = rtype($in); | |||||||||||||||||||||||||||
| 31 | 14692 | ▶ | return "$in" unless $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # Look past overloading | ||||||||||||||||||||||||||||
| 34 | 4610 | ▶ | my $class = blessed($in) || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
builtin::blessed($in) || ''
MC/DC100%1/1
builtin::blessed($in) || ''
builtin::blessed($in)
Truth table100%2/2
A
A= builtin::blessed($in)
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4610 | my $it = sprintf('0x%x', refaddr($in)); | |||||||||||||||||||||||||||
| 37 | 4610 | my $ref = "$type($it)"; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 4610 | ▶ | return $ref unless $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 2493 | my $out = "$class=$ref"; | |||||||||||||||||||||||||||
| 42 | 2493 | ▶ | if ($class =~ m/bool/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 8 | ▶ | my $bool = $in ? 'TRUE' : 'FALSE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 8 | return "<$bool: $out>"; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 2485 | return $out; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 177 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||