8 use Memoize 0.45 qw(memoize unmemoize);
10 # use Memoize::NDBM_File;
11 # $Memoize::NDBM_File::Verbose = 0;
27 eval {require Memoize::NDBM_File};
36 if (eval {require File::Spec::Functions}) {
37 File::Spec::Functions->import();
39 *catfile = sub { join '/', @_ };
41 $tmpdir = $ENV{TMP} || $ENV{TMPDIR} || '/tmp';
42 $file = catfile($tmpdir, "md$$");
43 1 while unlink $file, "$file.dir", "$file.pag";
44 tryout('Memoize::NDBM_File', $file, 1); # Test 1..4
45 1 while unlink $file, "$file.dir", "$file.pag";
48 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\n");
78 print (($t4 == 5) ? "ok $testno\n" : "not ok $testno\n");