File Coverage

inc/Test/Deep/Cache.pm
Criterion Covered Total %
statement 29 35 82.8
branch 2 6 33.3
condition n/a
subroutine 8 9 88.8
pod 0 6 0.0
total 39 56 69.6


line stmt bran cond sub pod time code
1 2     2   10 #line 1
  2         4  
  2         65  
2 2     2   11 use strict;
  2         4  
  2         64  
3             use warnings;
4              
5             package Test::Deep::Cache;
6 2     2   1196  
  2         5  
  2         793  
7             use Test::Deep::Cache::Simple;
8              
9             sub new
10 47     47 0 76 {
11             my $pkg = shift;
12 47         122  
13             my $self = bless {}, $pkg;
14 47         215  
15 47         141 $self->{expects} = [Test::Deep::Cache::Simple->new];
16             $self->{normal} = [Test::Deep::Cache::Simple->new];
17 47         113  
18             $self->local;
19 47         169  
20             return $self;
21             }
22              
23             sub add
24 378     378 0 468 {
25             my $self = shift;
26 378         614  
27             my $type = $self->type;
28 378         1237  
29             $self->{$type}->[-1]->add(@_);
30             }
31              
32             sub cmp
33             {
34             # go through all the caches to see if we know this one
35 378     378 0 433  
36             my $self = shift;
37 378         713  
38             my $type = $self->type;
39 378         435  
  378         842  
40             foreach my $cache (@{$self->{$type}})
41 756 50       2149 {
42             return 1 if $cache->cmp(@_);
43             }
44 378         1075  
45             return 0
46             }
47              
48             sub local
49 47     47 0 57 {
50             my $self = shift;
51 47         129  
52             foreach my $type (qw( expects normal ))
53 94         98 {
  94         302  
54             push(@{$self->{$type}}, Test::Deep::Cache::Simple->new);
55             }
56             }
57              
58             sub finish
59 0     0 0 0 {
60             my $self = shift;
61 0         0  
62             my $keep = shift;
63 0         0  
64             foreach my $type (qw( expects normal ))
65 0         0 {
66             my $caches = $self->{$type};
67 0         0  
68             my $last = pop @$caches;
69 0 0       0  
70             $caches->[-1]->absorb($last) if $keep;
71             }
72             }
73              
74             sub type
75 756 50   756 0 1546 {
76             return $Test::Deep::Expects ? "expects" : "normal";
77             }
78              
79             1;