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