Upgrade to ExtUtils::MakeMaker 6.28
[p5sagit/p5-mst-13.2.git] / lib / Memoize / t / tie_storable.t
index 2dd77d0..de3b8dc 100644 (file)
@@ -3,9 +3,14 @@
 
 use lib qw(. ..);
 use Memoize 0.45 qw(memoize unmemoize);
-# use Memoize::Storable;
 # $Memoize::Storable::Verbose = 0;
 
+eval {require Memoize::Storable};
+if ($@) {
+  print "1..0\n";
+  exit 0;
+}
+
 sub i {
   $_[0];
 }
@@ -28,24 +33,19 @@ if ($@) {
 
 print "1..4\n";
 
-
-if (eval {require File::Spec::Functions}) {
- File::Spec::Functions->import();
-} else {
-  *catfile = sub { join '/', @_ };
-}
-$tmpdir = $ENV{TMP} || $ENV{TMPDIR} ||  '/tmp';  
-$file = catfile($tmpdir, "storable$$");
-unlink $file;
+$file = "storable$$";
+1 while unlink $file;
 tryout('Memoize::Storable', $file, 1);  # Test 1..4
-unlink $file;
+1 while unlink $file;
 
 sub tryout {
   my ($tiepack, $file, $testno) = @_;
 
+  tie my %cache => $tiepack, $file
+    or die $!;
 
   memoize 'c5', 
-  SCALAR_CACHE => ['TIE', $tiepack, $file], 
+  SCALAR_CACHE => [HASH => \%cache],
   LIST_CACHE => 'FAULT'
     ;
 
@@ -61,7 +61,7 @@ sub tryout {
   # Now something tricky---we'll memoize c23 with the wrong table that
   # has the 5 already cached.
   memoize 'c23', 
-  SCALAR_CACHE => ['TIE', $tiepack, $file], 
+  SCALAR_CACHE => [HASH => \%cache],
   LIST_CACHE => 'FAULT'
     ;