3 # $Id: forgive.t,v 0.7.1.1 2000/08/03 22:04:45 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the terms of the Artistic License,
8 # as specified in the README file that comes with the distribution.
10 # Original Author: Ulrich Pfeifer
11 # (C) Copyright 1997, Universitat Dortmund, all rights reserved.
14 # Revision 0.7.1.1 2000/08/03 22:04:45 ram
15 # Baseline for second beta release.
17 # Revision 0.7 2000/08/03 22:04:45 ram
18 # Baseline for second beta release.
25 require Config; import Config;
26 if ($Config{'extensions'} !~ /\bStorable\b/) {
27 print "1..0 # Skip: Storable was not built\n";
32 use Storable qw(store retrieve);
38 my $bad = ['foo', sub { 1 }, 'bar'];
41 eval {$result = store ($bad , 'store')};
42 print ((!defined $result)?"ok $test\n":"not ok $test\n"); $test++;
43 print (($@ ne '')?"ok $test\n":"not ok $test\n"); $test++;
45 $Storable::forgive_me=1;
47 my $devnull = File::Spec->devnull;
49 open(SAVEERR, ">&STDERR");
50 open(STDERR, ">$devnull") or
51 ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
53 eval {$result = store ($bad , 'store')};
55 open(STDERR, ">&SAVEERR");
57 print ((defined $result)?"ok $test\n":"not ok $test\n"); $test++;
58 print (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++;
60 my $ret = retrieve('store');
61 print ((defined $ret)?"ok $test\n":"not ok $test\n"); $test++;
62 print (($ret->[0] eq 'foo')?"ok $test\n":"not ok $test\n"); $test++;
63 print (($ret->[2] eq 'bar')?"ok $test\n":"not ok $test\n"); $test++;
64 print ((ref $ret->[1] eq 'SCALAR')?"ok $test\n":"not ok $test\n"); $test++;
67 END { 1 while unlink 'store' }