Commit | Line | Data |
---|---|---|
7a6a85bf | 1 | #!./perl |
7a6a85bf RG |
2 | # |
3 | # Copyright (c) 1995-2000, Raphael Manfredi | |
4 | # | |
9e21b3d0 JH |
5 | # You may redistribute only under the same terms as Perl 5, as specified |
6 | # in the README file that comes with the distribution. | |
7a6a85bf RG |
7 | # |
8 | # Original Author: Ulrich Pfeifer | |
9 | # (C) Copyright 1997, Universitat Dortmund, all rights reserved. | |
10 | # | |
7a6a85bf RG |
11 | |
12 | sub BEGIN { | |
48c887dd | 13 | unshift @INC, 't'; |
1afdebce | 14 | unshift @INC, 't/compat' if $] < 5.006002; |
9f233367 | 15 | require Config; import Config; |
0c384302 | 16 | if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) { |
9f233367 PP |
17 | print "1..0 # Skip: Storable was not built\n"; |
18 | exit 0; | |
19 | } | |
7a6a85bf RG |
20 | } |
21 | ||
22 | use Storable qw(store retrieve); | |
dddb60fc | 23 | use Test::More; |
372cb964 | 24 | |
197b90bc | 25 | # problems with 5.00404 when in an BEGIN block, so this is defined here |
87baa35a | 26 | if (!eval { require File::Spec; 1 } || $File::Spec::VERSION < 0.8) { |
dddb60fc | 27 | plan(skip_all => "File::Spec 0.8 needed"); |
a2307be4 NC |
28 | # Mention $File::Spec::VERSION again, as 5.00503's harness seems to have |
29 | # warnings on. | |
30 | exit $File::Spec::VERSION; | |
197b90bc | 31 | } |
7a6a85bf | 32 | |
dddb60fc | 33 | plan(tests => 8); |
7a6a85bf | 34 | |
464b080a SR |
35 | *GLOB = *GLOB; # peacify -w |
36 | my $bad = ['foo', \*GLOB, 'bar']; | |
7a6a85bf RG |
37 | my $result; |
38 | ||
39 | eval {$result = store ($bad , 'store')}; | |
dddb60fc NC |
40 | is($result, undef); |
41 | isnt($@, ''); | |
7a6a85bf RG |
42 | |
43 | $Storable::forgive_me=1; | |
44 | ||
29fc1735 JH |
45 | my $devnull = File::Spec->devnull; |
46 | ||
7a6a85bf | 47 | open(SAVEERR, ">&STDERR"); |
f42118b2 | 48 | open(STDERR, ">$devnull") or |
7a6a85bf RG |
49 | ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) ); |
50 | ||
51 | eval {$result = store ($bad , 'store')}; | |
52 | ||
53 | open(STDERR, ">&SAVEERR"); | |
54 | ||
dddb60fc NC |
55 | isnt($result, undef); |
56 | is($@, ''); | |
7a6a85bf RG |
57 | |
58 | my $ret = retrieve('store'); | |
dddb60fc NC |
59 | isnt($ret, undef); |
60 | is($ret->[0], 'foo'); | |
61 | is($ret->[2], 'bar'); | |
62 | is(ref $ret->[1], 'SCALAR'); | |
7a6a85bf RG |
63 | |
64 | ||
29fc1735 | 65 | END { 1 while unlink 'store' } |