blib/lib/Test2/Compare/Meta.pm

filter: Statementstmt 100% 66 / 66 Branchbran 100% 16 / 16 Conditioncond 85.7% 6 / 7 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 18 / 18 Podpod 30.0% 3 / 10 totaltotal 92.5% 112 / 121 CC 13 SCAR 11.0
CC
13
Cov
99%
add_prop
7.0
get_prop_size
4.0
init
2.0
CRAP 3.0
« blib/lib/Test2/Compare/Pattern.pm ↑ Summary blib/lib/Test2/Event/Ok.pm »
1 package Test2::Compare::Meta;
2 176 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 176 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 176 ▶use Test2::Compare::Delta();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 176 ▶use Test2::Compare::Isa();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 176 ▶use base 'Test2::Compare::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 176 our $VERSION = '1.302226';
11  
12 176 ▶use Test2::Util::HashBase qw/items/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 176 ▶use Carp qw/croak confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 176 ▶use Scalar::Util qw/reftype blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1870 ▶sub init {
Subroutine init: called CC=2 SCAR=6.9
Pod undocumented
18 1870 my $self = shift;
19 1870 ▶ $self->{+ITEMS} ||= [];
Condition100%2/2
$self->{"items"} ||= []
l!l
11869
MC/DC100%1/1
$self->{"items"} ||= []
$self->{"items"}
Truth table100%2/2
A
A= $self->{"items"}
Aresult
11
00
20 1870 $self->SUPER::init();
21 }
22  
23 2 ▶sub name { '<META CHECKS>' }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
24  
25 8 ▶sub verify {
Subroutine verify: called CC=2 SCAR=6.9
Pod documented
26 8 my $self = shift;
27 8 my %params = @_;
28 8 ▶ return $params{exists} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$params{'exists'} ? : 7 1 8
29 }
30  
31 1974 ▶sub add_prop {
Subroutine add_prop: called CC=7 SCAR=19.5
Pod undocumented
32 1974 my $self = shift;
33 1974 my ($name, $check) = @_;
34  
35 1974 ▶ croak "prop name is required"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 1 1973 1974
36 unless defined $name;
37  
38 1973 ▶ croak "check is required"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $check 1 1972 1973
39 unless defined $check;
40  
41 1972 my $meth = "get_prop_$name";
42 1972 ▶ croak "'$name' is not a known property"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($meth) 1 1971 1972
43 unless $self->can($meth);
44  
45 1971 ▶ if ($name eq 'isa') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "isa") 3 1968 1971
46 3 ▶ if (blessed($check) && $check->isa('Test2::Compare::Wildcard')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($check) and $check->isa('Test2::Compare::Wildcard')) { } 1 2 3
Condition66%2/3
builtin::blessed($check) and $check->isa("Test2::Compare::Wildcard")
!ll&&!rl&&r
201
MC/DC50%1/2
builtin::blessed($check) and $check->isa("Test2::Compare::Wildcard")
builtin::blessed($check) $check->isa("Test2::Compare::Wildcard")
Truth table66%2/3
A and B
A= builtin::blessed($check)B= $check->isa("Test2::Compare::Wildcard")
ABresult
0X0
100
111
47 # Carry forward file and lines that are set in Test2::Tools::Compare::prop.
48 1 $check = Test2::Compare::Isa->new(
49 input => $check->expect,
50 file => $check->file,
51 lines => $check->lines,
52 );
53 } else {
54 2 $check = Test2::Compare::Isa->new(input => $check);
55 }
56 }
57  
58 1971 push @{$self->{+ITEMS}} => [$meth, $check, $name];
59 }
60  
61 1874 ▶sub deltas {
Subroutine deltas: called CC=2 SCAR=6.9
Pod documented
62 1874 my $self = shift;
63 1874 my %params = @_;
64 1874 my ($got, $convert, $seen) = @params{qw/got convert seen/};
65  
66 1874 my @deltas;
67 1874 my $items = $self->{+ITEMS};
68  
69 1874 for my $set (@$items) {
70 1995 my ($meth, $check, $name) = @$set;
71  
72 1995 $check = $convert->($check);
73  
74 1995 my $val = $self->$meth($got);
75  
76 1995 push @deltas => $check->run(
77 id => [META => $name],
78 got => $val,
79 convert => $convert,
80 seen => $seen,
81 );
82 }
83  
84 1874 return @deltas;
85 }
86  
87 1868 ▶sub get_prop_blessed { blessed($_[1]) }
Subroutine get_prop_blessed: called CC=1 SCAR=0.0
Pod undocumented
88  
89 12 ▶sub get_prop_reftype { reftype($_[1]) }
Subroutine get_prop_reftype: called CC=1 SCAR=0.0
Pod undocumented
90  
91 9 ▶sub get_prop_isa { $_[1] }
Subroutine get_prop_isa: called CC=1 SCAR=0.0
Pod undocumented
92  
93 5 ▶sub get_prop_this { $_[1] }
Subroutine get_prop_this: called CC=1 SCAR=0.0
Pod undocumented
94  
95 9 ▶sub get_prop_size {
Subroutine get_prop_size: called CC=4 SCAR=13.9
Pod undocumented
96 9 my $self = shift;
97 9 my ($it) = @_;
98  
99 9 ▶ my $type = reftype($it) || '';
Condition100%2/2
builtin::reftype($it) || ''
l!l
81
MC/DC100%1/1
builtin::reftype($it) || ''
builtin::reftype($it)
Truth table100%2/2
A
A= builtin::reftype($it)
Aresult
11
00
100  
101 9 ▶ return scalar @$it if $type eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "ARRAY" 5 4 9
102 4 ▶ return scalar keys %$it if $type eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "HASH" 3 1 4
103 1 return undef;
104 }
105  
106 176 1;
107  
108 __END__
« blib/lib/Test2/Compare/Pattern.pm ↑ Summary blib/lib/Test2/Event/Ok.pm »