1N/A#!./perl
1N/A#
1N/A# Copyright (c) 1995-2000, Raphael Manfredi
1N/A#
1N/A# You may redistribute only under the same terms as Perl 5, as specified
1N/A# in the README file that comes with the distribution.
1N/A#
1N/A# Original Author: Ulrich Pfeifer
1N/A# (C) Copyright 1997, Universitat Dortmund, all rights reserved.
1N/A#
1N/A
1N/Asub BEGIN {
1N/A if ($ENV{PERL_CORE}){
1N/A chdir('t') if -d 't';
1N/A @INC = ('.', '../lib');
1N/A } else {
1N/A unshift @INC, 't';
1N/A }
1N/A require Config; import Config;
1N/A if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
1N/A print "1..0 # Skip: Storable was not built\n";
1N/A exit 0;
1N/A }
1N/A}
1N/A
1N/Ause Storable qw(store retrieve);
1N/A
1N/A# problems with 5.00404 when in an BEGIN block, so this is defined here
1N/Aif (!eval { require File::Spec; 1 } || $File::Spec::VERSION < 0.8) {
1N/A print "1..0 # Skip: File::Spec 0.8 needed\n";
1N/A exit 0;
1N/A # Mention $File::Spec::VERSION again, as 5.00503's harness seems to have
1N/A # warnings on.
1N/A exit $File::Spec::VERSION;
1N/A}
1N/A
1N/Aprint "1..8\n";
1N/A
1N/Amy $test = 1;
1N/A*GLOB = *GLOB; # peacify -w
1N/Amy $bad = ['foo', \*GLOB, 'bar'];
1N/Amy $result;
1N/A
1N/Aeval {$result = store ($bad , 'store')};
1N/Aprint ((!defined $result)?"ok $test\n":"not ok $test\n"); $test++;
1N/Aprint (($@ ne '')?"ok $test\n":"not ok $test\n"); $test++;
1N/A
1N/A$Storable::forgive_me=1;
1N/A
1N/Amy $devnull = File::Spec->devnull;
1N/A
1N/Aopen(SAVEERR, ">&STDERR");
1N/Aopen(STDERR, ">$devnull") or
1N/A ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
1N/A
1N/Aeval {$result = store ($bad , 'store')};
1N/A
1N/Aopen(STDERR, ">&SAVEERR");
1N/A
1N/Aprint ((defined $result)?"ok $test\n":"not ok $test\n"); $test++;
1N/Aprint (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++;
1N/A
1N/Amy $ret = retrieve('store');
1N/Aprint ((defined $ret)?"ok $test\n":"not ok $test\n"); $test++;
1N/Aprint (($ret->[0] eq 'foo')?"ok $test\n":"not ok $test\n"); $test++;
1N/Aprint (($ret->[2] eq 'bar')?"ok $test\n":"not ok $test\n"); $test++;
1N/Aprint ((ref $ret->[1] eq 'SCALAR')?"ok $test\n":"not ok $test\n"); $test++;
1N/A
1N/A
1N/AEND { 1 while unlink 'store' }