|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/local/share/perl5/Test/Deep/ |
Upload File : |
use strict;
use warnings;
package Test::Deep::Cache;
use Test::Deep::Cache::Simple;
sub new
{
my $pkg = shift;
my $self = bless {}, $pkg;
$self->{expects} = [Test::Deep::Cache::Simple->new];
$self->{normal} = [Test::Deep::Cache::Simple->new];
$self->local;
return $self;
}
sub add
{
my $self = shift;
my $type = $self->type;
$self->{$type}->[-1]->add(@_);
}
sub cmp
{
# go through all the caches to see if we know this one
my $self = shift;
my $type = $self->type;
foreach my $cache (@{$self->{$type}})
{
return 1 if $cache->cmp(@_);
}
return 0
}
sub local
{
my $self = shift;
foreach my $type (qw( expects normal ))
{
push(@{$self->{$type}}, Test::Deep::Cache::Simple->new);
}
}
sub finish
{
my $self = shift;
my $keep = shift;
foreach my $type (qw( expects normal ))
{
my $caches = $self->{$type};
my $last = pop @$caches;
$caches->[-1]->absorb($last) if $keep;
}
}
sub type
{
return $Test::Deep::Expects ? "expects" : "normal";
}
1;