| 1 | package Devel::Walk::Unstorable; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Devel::Walk (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | our %EXPORT_TAGS = ( 'all' => [ qw( unstorable ) ] ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | our @EXPORT = qw( unstorable ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | ############################################### | ||||||||||||||||||||||||||||||||||||||||||
| 17 | sub unstorable | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unstorable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my( $obj, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $S = Devel::Walk::Unstorable->new; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | $S->walk( $obj, $name ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | return $S->list; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | ############################################### | ||||||||||||||||||||||||||||||||||||||||||
| 26 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | return bless {@_}, $package; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub walk | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
walk: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my( $self, $obj, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | local $self->{LAST}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | $self->{list} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"list"} ||= []
MC/DC0%0/1
$self->{"list"} ||= []
$self->{"list"}
Truth table50%1/2
A
A= $self->{"list"}
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | Devel::Walk::walk( $obj, sub { $self->__unstorable( @_ ); }, $name ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | push @{ $self->{list} }, $self->{LAST} if defined $self->{LAST} and @{ $self->{list} } and | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | $self->{list}[-1] ne $self->{LAST}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $self->{"LAST"} and @{$self->{"list"};} and $self->{"list"}[-1] ne $self->{"LAST"}
defined $self->{"LAST"} and @{$self->{"list"};}
MC/DC0%0/3
defined $self->{"LAST"} and @{$self->{"list"};} and $self->{"list"}[-1] ne $self->{"LAST"}
defined $self->{"LAST"}
@{$self->{"list"};}
$self->{"list"}[-1] ne $self->{"LAST"}
Truth table25%1/4
A and B and C
A= defined $self->{"LAST"}B= @{$self->{"list"};}C= $self->{"list"}[-1] ne $self->{"LAST"}
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | sub list { @{ $_[0]->{list} } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub __deepest | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 38 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__deepest: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 38 | my( $self, $old, $new ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 38 | ▶ | return unless defined $old; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 32 | my $ol = length( $old ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | # $old = '$something->{one}' | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # $new = '$something->{one}[0]' | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # $old is not deepest | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 32 | ▶ | return if substr( $new, 0, $ol ) eq $old; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # $old = '$something->{one}' | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # $new = '$${$something->{one}}{more}' | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # $old is not deepest | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | return if $new =~ /^\$\$\{\Q$old\E\}/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | # $old = '$something->{one}' | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # $new = '$something->{two}' | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # $old is deepest | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # warn "deepest='$old'"; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | sub __unstorable | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 38 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__unstorable: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 38 | my( $self, $loc, $obj ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 38 | require 'Storable.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 38 | ▶ | if( $self->__deepest( $self->{LAST}, $loc ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | # warn "deepest=$self->{LAST}"; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | push @{ $self->{list} }, $self->{LAST}; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | $self->{LAST} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 38 | ▶ | if( $self->check( $loc, $obj ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | # warn "$loc is unstorable"; | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 20 | $self->{LAST} = $loc; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 20 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # warn "$loc is storable"; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 18 | return; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | sub check | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 38 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 38 | my( $self, $loc, $obj ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 38 | ▶ | return 1 if ref( $obj ) and not eval { $SIG{__DIE__} = 'DEFAULT'; Storable::freeze( $obj ); 1; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $obj and not eval {
do {
$SIG{"__DIE__"} = "DEFAULT";
Storable::freeze($obj);
1
}
}
MC/DC100%2/2
ref $obj and not eval {
do {
$SIG{"__DIE__"} = "DEFAULT";
Storable::freeze($obj);
1
}
}
ref $obj
not eval {
do {
$SIG{"__DIE__"} = "DEFAULT";
Storable::freeze($obj);
1
}
}
Truth table100%3/3
A and not(B)
A= ref $objB= not eval {
do {
$SIG{"__DIE__"} = "DEFAULT";
Storable::freeze($obj);
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | return; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||||||||||||||||||||||||