8 use Memoize 0.52 qw(memoize unmemoize);
10 eval {require Memoize::AnyDBM_File};
24 $ARG = 'Keith Bostic is a pinhead';
36 if (eval {require File::Spec::Functions}) {
37 File::Spec::Functions->import('tmpdir', 'catfile');
40 *catfile = sub { join '/', @_ };
41 $tmpdir = $ENV{TMP} || $ENV{TMPDIR} || '/tmp';
43 $file = catfile($tmpdir, "md$$");
44 @files = ($file, "$file.db", "$file.dir", "$file.pag");
45 1 while unlink @files;
48 tryout('Memoize::AnyDBM_File', $file, 1); # Test 1..4
49 # tryout('DB_File', $file, 1); # Test 1..4
50 1 while unlink $file, "$file.dir", "$file.pag";
53 my ($tiepack, $file, $testno) = @_;
55 tie my %cache => $tiepack, $file, O_RDWR | O_CREAT, 0666
59 SCALAR_CACHE => [HASH => \%cache],
65 print (($t1 == 5) ? "ok $testno\n" : "not ok $testno\n");
67 print (($t2 == 5) ? "ok $testno\n" : "not ok $testno\n");
70 # Now something tricky---we'll memoize c23 with the wrong table that
71 # has the 5 already cached.
73 SCALAR_CACHE => ['HASH', \%cache],
80 print (($t3 == 5) ? "ok $testno\n" : "not ok $testno # Result $t3\n");
82 print (($t4 == 5) ? "ok $testno\n" : "not ok $testno # Result $t4\n");
87 my @present = grep -e, @files;
88 if (@present && (@failed = grep { not unlink } @present)) {
89 warn "Can't unlink @failed! ($!)";