4 use Memoize 0.52 qw(memoize unmemoize);
6 eval {require Memoize::AnyDBM_File};
20 $ARG = 'Keith Bostic is a pinhead';
32 if (eval {require File::Spec::Functions}) {
33 File::Spec::Functions->import('tmpdir', 'catfile');
36 *catfile = sub { join '/', @_ };
37 $tmpdir = $ENV{TMP} || $ENV{TMPDIR} || '/tmp';
39 $file = catfile($tmpdir, "md$$");
40 @files = ($file, "$file.db", "$file.dir", "$file.pag");
41 1 while unlink @files;
44 tryout('Memoize::AnyDBM_File', $file, 1); # Test 1..4
45 # tryout('DB_File', $file, 1); # Test 1..4
46 1 while unlink $file, "$file.dir", "$file.pag";
49 my ($tiepack, $file, $testno) = @_;
51 tie my %cache => $tiepack, $file, O_RDWR | O_CREAT, 0666
55 SCALAR_CACHE => [HASH => \%cache],
61 print (($t1 == 5) ? "ok $testno\n" : "not ok $testno\n");
63 print (($t2 == 5) ? "ok $testno\n" : "not ok $testno\n");
66 # Now something tricky---we'll memoize c23 with the wrong table that
67 # has the 5 already cached.
69 SCALAR_CACHE => ['HASH', \%cache],
76 print (($t3 == 5) ? "ok $testno\n" : "not ok $testno # Result $t3\n");
78 print (($t4 == 5) ? "ok $testno\n" : "not ok $testno # Result $t4\n");
83 my @present = grep -e, @files;
84 if (@present && (@failed = grep { not unlink } @present)) {
85 warn "Can't unlink @failed! ($!)";