blib/lib/Scalar/ValueTags/LineageTracking.pm

filter: Statementstmt 90.7% 39 / 43 Branchbran 71.4% 10 / 14 Conditioncond 50.0% 6 / 12 MC/DCmcdc 50.0% 4 / 8 Subroutinesub 92.8% 13 / 14 Podpod 60.0% 3 / 5 totaltotal 78.1% 75 / 96 SCAR 25.8
CC
12
Cov
80%
add_data_source
30.0
set_data_source
5.0
__ANON__
2.0
CRAP 13.2
↑ Summary Build »
1 package Scalar::ValueTags::LineageTracking 0.002;
2  
3 1 ▶use v5.44;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Scalar::ValueTags 0.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Ref::Util qw( is_plain_ref is_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 use Scalar::ValueTags qw(
15 SVTAGS_UNIQUE_REF_ARRAY
16 SVTAGS_UNIQUE_HASH
17 add_value_tag
18 clear_value_tags
19 get_value_tags
20 register_value_tags_type
21 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 class Scalar::ValueTags::LineageTracking {
24 1 field $tag_type :param :reader //= 'string';
25  
26 1 field $vt_type :reader(_vt_type) :writer(_set_vt_type);
27  
28 ADJUST {
29 4 ▶ croak "Invalid tag_type: must be 'ref' or 'string'"
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $self->tag_type =~ /\A(ref|string)\Z/nu 1 3 4
30 unless $self->&tag_type =~ m/\A(ref|string)\Z/n;
31 }
32  
33 ADJUST {
34 3 ▶ $self->_set_vt_type(
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$self->tag_type eq 'string' ? : 2 1 3
35 register_value_tags_type(
36 $self->&tag_type eq 'string'
37 ? SVTAGS_UNIQUE_HASH
38 : SVTAGS_UNIQUE_REF_ARRAY
39 )
40 );
41 }
42  
43 ▶ method add_data_source( $var_ref, $data_source ) {
Subroutine add_data_source: not called CC=5 SCAR=34.0
Pod undocumented
44 0 my $tag_type = $self->&tag_type;
45  
46 0 ▶ croak 'invalid data_source: must be string'
Branch: 1 branch
BranchTrueFalseTotal
if $tag_type eq "string" and is_ref($data_source) 0 0 0
Condition0%0/3
$tag_type eq "string" and is_ref($data_source)
!ll&&!rl&&r
000
MC/DC0%0/2
$tag_type eq "string" and is_ref($data_source)
$tag_type eq "string" is_ref($data_source)
Truth table0%0/3
A and B
A= $tag_type eq "string"B= is_ref($data_source)
ABresult
0X0
100
111
47 if $tag_type eq 'string' && is_ref($data_source);
48 0 ▶ croak 'invalid data_source: must be unblessed ref'
Branch: 1 branch
BranchTrueFalseTotal
if $tag_type eq "ref" and not is_plain_ref($data_source) 0 0 0
Condition0%0/3
$tag_type eq "ref" and not is_plain_ref($data_source)
!ll&&!rl&&r
000
MC/DC0%0/2
$tag_type eq "ref" and not is_plain_ref($data_source)
$tag_type eq "ref" not is_plain_ref($data_source)
Truth table0%0/3
A and not(B)
A= $tag_type eq "ref"B= not is_plain_ref($data_source)
ABresult
0X0
100
111
49 if $tag_type eq 'ref' && !is_plain_ref($data_source);
50  
51 0 add_value_tag( $self->&_vt_type, $var_ref, $data_source );
52 }
53  
54 ▶ method get_data_sources($var_ref) {
Subroutine get_data_sources: called CC=2 SCAR=6.9
Pod documented
55 21 my $tags = get_value_tags( $self->&_vt_type, $var_ref );
56 21 ▶ $tags = [ keys $tags->%* ]
Branch: 1 branch
BranchTrueFalseTotal
if $self->tag_type eq "string" 14 7 21
57 if $self->&tag_type eq 'string';
58 21 return $tags;
59 }
60  
61 ▶ method set_data_source( $var_ref, $data_source ) {
Subroutine set_data_source: called CC=5 SCAR=16.1
Pod documented
62 12 my $tag_type = $self->&tag_type;
63  
64 12 ▶ croak 'invalid data_source: must be string'
Branch: 1 branch
BranchTrueFalseTotal
if $tag_type eq "string" and is_ref($data_source) 2 10 12
Condition100%3/3
$tag_type eq "string" and is_ref($data_source)
!ll&&!rl&&r
462
MC/DC100%2/2
$tag_type eq "string" and is_ref($data_source)
$tag_type eq "string" is_ref($data_source)
Truth table100%3/3
A and B
A= $tag_type eq "string"B= is_ref($data_source)
ABresult
0X0
100
111
65 if $tag_type eq 'string' && is_ref($data_source);
66 10 ▶ croak 'invalid data_source: must be unblessed ref'
Branch: 1 branch
BranchTrueFalseTotal
if $tag_type eq "ref" and not is_plain_ref($data_source) 1 9 10
Condition100%3/3
$tag_type eq "ref" and not is_plain_ref($data_source)
!ll&&!rl&&r
631
MC/DC100%2/2
$tag_type eq "ref" and not is_plain_ref($data_source)
$tag_type eq "ref" not is_plain_ref($data_source)
Truth table100%3/3
A and not(B)
A= $tag_type eq "ref"B= not is_plain_ref($data_source)
ABresult
0X0
100
111
67 if $tag_type eq 'ref' && !is_plain_ref($data_source);
68  
69 9 my $vt_type = $self->&_vt_type;
70 9 clear_value_tags( $vt_type, $var_ref );
71 9 add_value_tag( $vt_type, $var_ref, $data_source );
72 }
73  
74 ▶ method clear_data_sources($var_ref) {
Subroutine clear_data_sources: called CC=1 SCAR=0.0
Pod documented
75 6 clear_value_tags( $self->&_vt_type, $var_ref );
76 }
77  
78 ▶ method get_and_clear_data_sources($var_ref) {
Subroutine get_and_clear_data_sources: called CC=1 SCAR=0.0
Pod undocumented
79 3 my $tags = $self->get_data_sources($var_ref);
80 3 $self->clear_data_sources($var_ref);
81 3 return $tags;
82 }
83 }
84  
85 1 1;
86 __END__
↑ Summary Build »