Do not try to load a feature bundle when doing "no VERSION"
[p5sagit/p5-mst-13.2.git] / dist / Storable / t / forgive.t
1 #!./perl
2 #
3 #  Copyright (c) 1995-2000, Raphael Manfredi
4 #  
5 #  You may redistribute only under the same terms as Perl 5, as specified
6 #  in the README file that comes with the distribution.
7 #
8 # Original Author: Ulrich Pfeifer
9 # (C) Copyright 1997, Universitat Dortmund, all rights reserved.
10 #
11
12 sub BEGIN {
13     unshift @INC, 't';
14     require Config; import Config;
15     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
16         print "1..0 # Skip: Storable was not built\n";
17         exit 0;
18     }
19 }
20
21 use Storable qw(store retrieve);
22
23 # problems with 5.00404 when in an BEGIN block, so this is defined here
24 if (!eval { require File::Spec; 1 } || $File::Spec::VERSION < 0.8) {
25     print "1..0 # Skip: File::Spec 0.8 needed\n";
26     exit 0;
27     # Mention $File::Spec::VERSION again, as 5.00503's harness seems to have
28     # warnings on.
29     exit $File::Spec::VERSION;
30 }
31
32 print "1..8\n";
33
34 my $test = 1;
35 *GLOB = *GLOB; # peacify -w
36 my $bad = ['foo', \*GLOB,  'bar'];
37 my $result;
38
39 eval {$result = store ($bad , 'store')};
40 print ((!defined $result)?"ok $test\n":"not ok $test\n"); $test++;
41 print (($@ ne '')?"ok $test\n":"not ok $test\n"); $test++;
42
43 $Storable::forgive_me=1;
44
45 my $devnull = File::Spec->devnull;
46
47 open(SAVEERR, ">&STDERR");
48 open(STDERR, ">$devnull") or 
49   ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
50
51 eval {$result = store ($bad , 'store')};
52
53 open(STDERR, ">&SAVEERR");
54
55 print ((defined $result)?"ok $test\n":"not ok $test\n"); $test++;
56 print (($@ eq '')?"ok $test\n":"not ok $test\n"); $test++;
57
58 my $ret = retrieve('store');
59 print ((defined $ret)?"ok $test\n":"not ok $test\n"); $test++;
60 print (($ret->[0] eq 'foo')?"ok $test\n":"not ok $test\n"); $test++;
61 print (($ret->[2] eq 'bar')?"ok $test\n":"not ok $test\n"); $test++;
62 print ((ref $ret->[1] eq 'SCALAR')?"ok $test\n":"not ok $test\n"); $test++;
63
64
65 END { 1 while unlink 'store' }