Commit | Line | Data |
7a6a85bf |
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'; |
8268a68b |
23 | unshift @INC, '../lib'; |
9f233367 |
24 | require Config; import Config; |
25 | if ($Config{'extensions'} !~ /\bStorable\b/) { |
26 | print "1..0 # Skip: Storable was not built\n"; |
27 | exit 0; |
28 | } |
7a6a85bf |
29 | } |
30 | |
31 | use Storable qw(store retrieve); |
29fc1735 |
32 | use File::Spec; |
7a6a85bf |
33 | |
34 | print "1..8\n"; |
35 | |
36 | my $test = 1; |
37 | my $bad = ['foo', sub { 1 }, 'bar']; |
38 | my $result; |
39 | |
40 | eval {$result = store ($bad , 'store')}; |
41 | print ((!defined $result)?"ok $test\n":"not ok $test\n"); $test++; |
42 | print (($@ ne '')?"ok $test\n":"not ok $test\n"); $test++; |
43 | |
44 | $Storable::forgive_me=1; |
45 | |
29fc1735 |
46 | my $devnull = File::Spec->devnull; |
47 | |
7a6a85bf |
48 | open(SAVEERR, ">&STDERR"); |
f42118b2 |
49 | open(STDERR, ">$devnull") or |
7a6a85bf |
50 | ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) ); |
51 | |
52 | eval {$result = store ($bad , 'store')}; |
53 | |
54 | open(STDERR, ">&SAVEERR"); |
55 | |
56 | print ((defined $result)?"ok $test\n":"not ok $test\n"); $test++; |
57 | print (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++; |
58 | |
59 | my $ret = retrieve('store'); |
60 | print ((defined $ret)?"ok $test\n":"not ok $test\n"); $test++; |
61 | print (($ret->[0] eq 'foo')?"ok $test\n":"not ok $test\n"); $test++; |
62 | print (($ret->[2] eq 'bar')?"ok $test\n":"not ok $test\n"); $test++; |
63 | print ((ref $ret->[1] eq 'SCALAR')?"ok $test\n":"not ok $test\n"); $test++; |
64 | |
65 | |
29fc1735 |
66 | END { 1 while unlink 'store' } |