3 # $Id: forgive.t,v 1.0.1.1 2000/09/01 19:40:42 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the same terms as Perl 5, as specified
8 # in the README file that comes with the distribution.
10 # Original Author: Ulrich Pfeifer
11 # (C) Copyright 1997, Universitat Dortmund, all rights reserved.
17 @INC = ('.', '../lib');
22 if ($File::Spec::VERSION < 0.8) {
23 print "1..0 # Skip: newer File::Spec needed\n";
26 require Config; import Config;
27 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
28 print "1..0 # Skip: Storable was not built\n";
33 use Storable qw(store retrieve);
39 my $bad = ['foo', sub { 1 }, 'bar'];
42 eval {$result = store ($bad , 'store')};
43 print ((!defined $result)?"ok $test\n":"not ok $test\n"); $test++;
44 print (($@ ne '')?"ok $test\n":"not ok $test\n"); $test++;
46 $Storable::forgive_me=1;
48 my $devnull = File::Spec->devnull;
50 open(SAVEERR, ">&STDERR");
51 open(STDERR, ">$devnull") or
52 ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
54 eval {$result = store ($bad , 'store')};
56 open(STDERR, ">&SAVEERR");
58 print ((defined $result)?"ok $test\n":"not ok $test\n"); $test++;
59 print (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++;
61 my $ret = retrieve('store');
62 print ((defined $ret)?"ok $test\n":"not ok $test\n"); $test++;
63 print (($ret->[0] eq 'foo')?"ok $test\n":"not ok $test\n"); $test++;
64 print (($ret->[2] eq 'bar')?"ok $test\n":"not ok $test\n"); $test++;
65 print ((ref $ret->[1] eq 'SCALAR')?"ok $test\n":"not ok $test\n"); $test++;
68 END { 1 while unlink 'store' }