Commit | Line | Data |
7a6a85bf |
1 | #!./perl |
2 | |
9e21b3d0 |
3 | # $Id: forgive.t,v 1.0.1.1 2000/09/01 19:40:42 ram Exp $ |
7a6a85bf |
4 | # |
5 | # Copyright (c) 1995-2000, Raphael Manfredi |
6 | # |
9e21b3d0 |
7 | # You may redistribute only under the same terms as Perl 5, as specified |
8 | # in the README file that comes with the distribution. |
7a6a85bf |
9 | # |
10 | # Original Author: Ulrich Pfeifer |
11 | # (C) Copyright 1997, Universitat Dortmund, all rights reserved. |
12 | # |
13 | # $Log: forgive.t,v $ |
9e21b3d0 |
14 | # Revision 1.0.1.1 2000/09/01 19:40:42 ram |
15 | # Baseline for first official release. |
7a6a85bf |
16 | # |
9e21b3d0 |
17 | # Revision 1.0 2000/09/01 19:40:41 ram |
18 | # Baseline for first official release. |
7a6a85bf |
19 | # |
20 | |
21 | sub BEGIN { |
22 | chdir('t') if -d 't'; |
20822f61 |
23 | @INC = '.'; |
24 | push @INC, '../lib'; |
9f233367 |
25 | require Config; import Config; |
26 | if ($Config{'extensions'} !~ /\bStorable\b/) { |
27 | print "1..0 # Skip: Storable was not built\n"; |
28 | exit 0; |
29 | } |
7a6a85bf |
30 | } |
31 | |
32 | use Storable qw(store retrieve); |
29fc1735 |
33 | use File::Spec; |
7a6a85bf |
34 | |
35 | print "1..8\n"; |
36 | |
37 | my $test = 1; |
38 | my $bad = ['foo', sub { 1 }, 'bar']; |
39 | my $result; |
40 | |
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++; |
44 | |
45 | $Storable::forgive_me=1; |
46 | |
29fc1735 |
47 | my $devnull = File::Spec->devnull; |
48 | |
7a6a85bf |
49 | open(SAVEERR, ">&STDERR"); |
f42118b2 |
50 | open(STDERR, ">$devnull") or |
7a6a85bf |
51 | ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) ); |
52 | |
53 | eval {$result = store ($bad , 'store')}; |
54 | |
55 | open(STDERR, ">&SAVEERR"); |
56 | |
57 | print ((defined $result)?"ok $test\n":"not ok $test\n"); $test++; |
58 | print (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++; |
59 | |
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++; |
65 | |
66 | |
29fc1735 |
67 | END { 1 while unlink 'store' } |