MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/lib/perl5/5.8.8/Test/Deep/Cache.pm
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;