3 # Copyright (c) 1995-2000, Raphael Manfredi
5 # You may redistribute only under the same terms as Perl 5, as specified
6 # in the README file that comes with the distribution.
12 @INC = ('.', '../lib', '../ext/Storable/t');
16 require Config; import Config;
17 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
18 print "1..0 # Skip: Storable was not built\n";
24 use Storable qw(store retrieve store_fd nstore_fd fd_retrieve);
31 $c->{attribute} = 'attrval';
32 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
33 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
34 $b, \$a, $a, $c, \$c, \%a);
36 print "not " unless defined store(\@a, 'store');
42 $root = retrieve('store');
43 print "not " unless defined $root;
49 print "not " unless $got eq $dumped;
52 1 while unlink 'store';
54 package FOO; @ISA = qw(Storable);
58 $self->{key} = \%main::a;
65 print "not " unless $foo->store('store');
68 print "not " unless open(OUT, '>>store');
72 print "not " unless defined store_fd(\@a, ::OUT);
74 print "not " unless defined nstore_fd($foo, ::OUT);
76 print "not " unless defined nstore_fd(\%a, ::OUT);
79 print "not " unless close(OUT);
82 print "not " unless open(OUT, 'store');
85 $r = fd_retrieve(::OUT);
86 print "not " unless defined $r;
88 print "not " unless &dump($foo) eq &dump($r);
91 $r = fd_retrieve(::OUT);
92 print "not " unless defined $r;
94 print "not " unless &dump(\@a) eq &dump($r);
97 $r = fd_retrieve(main::OUT);
98 print "not " unless defined $r;
100 print "not " unless &dump($foo) eq &dump($r);
103 $r = fd_retrieve(::OUT);
104 print "not " unless defined $r;
106 print "not " unless &dump(\%a) eq &dump($r);
109 eval { $r = fd_retrieve(::OUT); };
110 print "not " unless $@;
113 close OUT or die "Could not close: $!";
114 END { 1 while unlink 'store' }