Add Storable 0.7.2 from Raphael Manfredi,
[p5sagit/p5-mst-13.2.git] / t / lib / st-forgive.t
1 #!./perl
2
3 # $Id: forgive.t,v 0.7.1.1 2000/08/03 22:04:45 ram Exp $
4 #
5 #  Copyright (c) 1995-2000, Raphael Manfredi
6 #  
7 #  You may redistribute only under the terms of the Artistic License,
8 #  as specified in the README file that comes with the distribution.
9 #
10 # Original Author: Ulrich Pfeifer
11 # (C) Copyright 1997, Universitat Dortmund, all rights reserved.
12 #
13 # $Log: forgive.t,v $
14 # Revision 0.7.1.1  2000/08/03 22:04:45  ram
15 # Baseline for second beta release.
16 #
17 # Revision 0.7  2000/08/03 22:04:45  ram
18 # Baseline for second beta release.
19 #
20
21 sub BEGIN {
22     chdir('t') if -d 't';
23     unshift @INC, '../lib';
24 }
25
26 use Storable qw(store retrieve);
27
28 print "1..8\n";
29
30 my $test = 1;
31 my $bad = ['foo', sub { 1 },  'bar'];
32 my $result;
33
34 eval {$result = store ($bad , 'store')};
35 print ((!defined $result)?"ok $test\n":"not ok $test\n"); $test++;
36 print (($@ ne '')?"ok $test\n":"not ok $test\n"); $test++;
37
38 $Storable::forgive_me=1;
39
40 open(SAVEERR, ">&STDERR");
41 open(STDERR, ">/dev/null") or 
42   ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
43
44 eval {$result = store ($bad , 'store')};
45
46 open(STDERR, ">&SAVEERR");
47
48 print ((defined $result)?"ok $test\n":"not ok $test\n"); $test++;
49 print (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++;
50
51 my $ret = retrieve('store');
52 print ((defined $ret)?"ok $test\n":"not ok $test\n"); $test++;
53 print (($ret->[0] eq 'foo')?"ok $test\n":"not ok $test\n"); $test++;
54 print (($ret->[2] eq 'bar')?"ok $test\n":"not ok $test\n"); $test++;
55 print ((ref $ret->[1] eq 'SCALAR')?"ok $test\n":"not ok $test\n"); $test++;
56
57
58 END { unlink 'store' }