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