| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Test::Deep::HashKeysOnly 1.205; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Test::Deep::Ref; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | sub init | ||||||||||||||||||||||||||||
| 9 | 21 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 21 | my %keys; | |||||||||||||||||||||||||||
| 13 | 21 | @keys{@_} = (); | |||||||||||||||||||||||||||
| 14 | 21 | $self->{val} = \%keys; | |||||||||||||||||||||||||||
| 15 | 21 | $self->{keys} = [sort @_]; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | sub descend | ||||||||||||||||||||||||||||
| 19 | 21 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
descend: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 21 | 21 | my $hash = shift; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 21 | my $data = $self->data; | |||||||||||||||||||||||||||
| 24 | 21 | my $exp = $self->{val}; | |||||||||||||||||||||||||||
| 25 | 21 | my %got; | |||||||||||||||||||||||||||
| 26 | 21 | @got{keys %$hash} = (); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 21 | my @missing; | |||||||||||||||||||||||||||
| 29 | my @extra; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 21 | ▶ | while (my ($key, $value) = each %$exp) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||
| 33 | 25 | ▶ | if (exists $got{$key}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | 22 | delete $got{$key}; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | else | ||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 3 | push(@missing, $key); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 21 | my @diags; | |||||||||||||||||||||||||||
| 44 | 21 | ▶ | if (@missing and (not $self->ignoreMissing)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@missing and not $self->ignoreMissing
MC/DC100%2/2
@missing and not $self->ignoreMissing
@missing
not $self->ignoreMissing
Truth table100%3/3
A and not(B)
A= @missingB= not $self->ignoreMissing
| |||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||
| 46 | 2 | push(@diags, "Missing: ".nice_list(\@missing)); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 21 | ▶ | if (%got and (not $self->ignoreExtra)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
%got and not $self->ignoreExtra
MC/DC100%2/2
%got and not $self->ignoreExtra
%got
not $self->ignoreExtra
Truth table100%3/3
A and not(B)
A= %gotB= not $self->ignoreExtra
| |||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||
| 51 | 2 | push(@diags, "Extra: ".nice_list([keys %got])); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 21 | ▶ | if (@diags) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 3 | $data->{diag} = join("\n", @diags); | |||||||||||||||||||||||||||
| 57 | 3 | return 0; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 18 | return 1; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub diagnostics | ||||||||||||||||||||||||||||
| 64 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
diagnostics: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 66 | 3 | my ($where, $last) = @_; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 3 | ▶ | my $type = $self->{IgnoreDupes} ? "Set" : "Bag"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 3 | my $error = $last->{diag}; | |||||||||||||||||||||||||||
| 71 | 3 | my $diag = <<EOM; | |||||||||||||||||||||||||||
| 72 | Comparing hash keys of $where | ||||||||||||||||||||||||||||
| 73 | $error | ||||||||||||||||||||||||||||
| 74 | EOM | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 3 | return $diag; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub nice_list | ||||||||||||||||||||||||||||
| 80 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
nice_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 4 | my $list = shift; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | return join(", ", | ||||||||||||||||||||||||||||
| 84 | 4 | (map {"'$_'"} sort @$list), | |||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub ignoreMissing | ||||||||||||||||||||||||||||
| 89 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ignoreMissing: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 2 | return 0; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub ignoreExtra | ||||||||||||||||||||||||||||
| 94 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ignoreExtra: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 2 | return 0; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | package Test::Deep::SuperHashKeysOnly 1.205; | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 6 | ▶ | use base 'Test::Deep::HashKeysOnly'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub ignoreMissing | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ignoreMissing: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 104 | 0 | return 0; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | sub ignoreExtra | ||||||||||||||||||||||||||||
| 108 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ignoreExtra: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 109 | 1 | return 1; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | package Test::Deep::SubHashKeysOnly 1.205; | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 6 | ▶ | use base 'Test::Deep::HashKeysOnly'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | sub ignoreMissing | ||||||||||||||||||||||||||||
| 117 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ignoreMissing: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 118 | 1 | return 1; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub ignoreExtra | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ignoreExtra: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 123 | 0 | return 0; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 6 | 1; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | __END__ | ||||||||||||||||||||||||||||