File Coverage

blib/lib/Test/Deep/HashKeys.pm
Criterion Covered Total %
statement 37 37 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 49 52 94.2


line stmt bran cond sub pod time code
1 8     8   63 use strict;
  8         18  
  8         409  
2 8     8   47 use warnings;
  8         14  
  8         612  
3              
4             package Test::Deep::HashKeys 1.205;
5              
6 8     8   374 use Test::Deep::Ref;
  8         16  
  8         74  
7              
8             sub init
9             {
10 43     43 0 177 my $self = shift;
11              
12 43         66 my %keys;
13 43         129 @keys{@_} = ();
14 43         764 $self->{val} = \%keys;
15 43         163 $self->{keys} = [sort @_];
16             }
17              
18             sub descend
19             {
20 43     43 0 63 my $self = shift;
21 43         83 my $got = shift;
22              
23 43         78 my $exp = $self->{val};
24              
25 43 100       146 return 0 unless $self->test_reftype($got, "HASH");
26              
27 21         60 return Test::Deep::descend($got, $self->hashkeysonly($exp));
28             }
29              
30             sub hashkeysonly
31             {
32 19     19 0 2997 require Test::Deep::HashKeysOnly;
33              
34 19         45 my $self = shift;
35 19         31 my $exp = shift;
36              
37 19         138 return Test::Deep::HashKeysOnly->new(keys %$exp)
38             }
39              
40             package Test::Deep::SuperHashKeys 1.205;
41              
42 8     8   83 use base 'Test::Deep::HashKeys';
  8         16  
  8         1724  
43              
44             sub hashkeysonly
45             {
46 1     1   3 require Test::Deep::HashKeysOnly;
47              
48 1         2 my $self = shift;
49 1         2 my $exp = shift;
50              
51 1         10 return Test::Deep::SuperHashKeysOnly->new(keys %$exp)
52             }
53              
54             package Test::Deep::SubHashKeys 1.205;
55              
56 8     8   57 use base 'Test::Deep::HashKeys';
  8         15  
  8         1484  
57              
58             sub hashkeysonly
59             {
60 1     1   3 require Test::Deep::HashKeysOnly;
61              
62 1         3 my $self = shift;
63 1         1 my $exp = shift;
64              
65 1         9 return Test::Deep::SubHashKeysOnly->new(keys %$exp)
66             }
67              
68             1;
69              
70             __END__