summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl0/lib/Test/Deep/Cache.pm
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2011-02-17 12:20:49 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2011-02-17 12:20:49 +0000
commit316ee97c621496b0fe3267f57cce81bee44ca1e6 (patch)
treecb2cab1192b4f58a7971af19b213e980bceda4b4 /Master/tlpkg/tlperl0/lib/Test/Deep/Cache.pm
parentcd0f87b5d39480d85ad9bd4ee37f520f75bed560 (diff)
Moving old tlperl prior to committing new one
git-svn-id: svn://tug.org/texlive/trunk@21422 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl0/lib/Test/Deep/Cache.pm')
-rwxr-xr-xMaster/tlpkg/tlperl0/lib/Test/Deep/Cache.pm78
1 files changed, 78 insertions, 0 deletions
diff --git a/Master/tlpkg/tlperl0/lib/Test/Deep/Cache.pm b/Master/tlpkg/tlperl0/lib/Test/Deep/Cache.pm
new file mode 100755
index 00000000000..e9ffd952740
--- /dev/null
+++ b/Master/tlpkg/tlperl0/lib/Test/Deep/Cache.pm
@@ -0,0 +1,78 @@
+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;