4 use Memoize 0.45 qw(memoize unmemoize);
6 # use Memoize::SDBM_File;
7 # $Memoize::GDBM_File::Verbose = 0;
23 eval {require Memoize::SDBM_File};
31 if (eval {require File::Spec::Functions}) {
32 File::Spec::Functions->import('tmpdir', 'catfile');
35 *catfile = sub { join '/', @_ };
36 $tmpdir = $ENV{TMP} || $ENV{TMPDIR} || '/tmp';
38 $file = catfile($tmpdir, "md$$");
39 1 while unlink $file, "$file.dir", "$file.pag";
40 tryout('Memoize::SDBM_File', $file, 1); # Test 1..4
41 1 while unlink $file, "$file.dir", "$file.pag";
44 my ($tiepack, $file, $testno) = @_;
46 tie my %cache => $tiepack, $file, O_RDWR | O_CREAT, 0666
50 SCALAR_CACHE => [HASH => \%cache],
56 print (($t1 == 5) ? "ok $testno\n" : "not ok $testno\n");
58 print (($t2 == 5) ? "ok $testno\n" : "not ok $testno\n");
61 # Now something tricky---we'll memoize c23 with the wrong table that
62 # has the 5 already cached.
64 SCALAR_CACHE => [HASH => \%cache],
71 print (($t3 == 5) ? "ok $testno\n" : "not ok $testno\n");
73 print (($t4 == 5) ? "ok $testno\n" : "not ok $testno\n");