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.
11 require Config; import Config;
12 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
13 print "1..0 # Skip: Storable was not built\n";
19 use Storable qw(store retrieve store_fd nstore_fd fd_retrieve);
26 $c->{attribute} = 'attrval';
27 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
28 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
29 $b, \$a, $a, $c, \$c, \%a);
31 print "not " unless defined store(\@a, 'store');
37 $root = retrieve('store');
38 print "not " unless defined $root;
44 print "not " unless $got eq $dumped;
47 1 while unlink 'store';
49 package FOO; @ISA = qw(Storable);
53 $self->{key} = \%main::a;
60 print "not " unless $foo->store('store');
63 print "not " unless open(OUT, '>>store');
67 print "not " unless defined store_fd(\@a, ::OUT);
69 print "not " unless defined nstore_fd($foo, ::OUT);
71 print "not " unless defined nstore_fd(\%a, ::OUT);
74 print "not " unless close(OUT);
77 print "not " unless open(OUT, 'store');
80 $r = fd_retrieve(::OUT);
81 print "not " unless defined $r;
83 print "not " unless &dump($foo) eq &dump($r);
86 $r = fd_retrieve(::OUT);
87 print "not " unless defined $r;
89 print "not " unless &dump(\@a) eq &dump($r);
92 $r = fd_retrieve(main::OUT);
93 print "not " unless defined $r;
95 print "not " unless &dump($foo) eq &dump($r);
98 $r = fd_retrieve(::OUT);
99 print "not " unless defined $r;
101 print "not " unless &dump(\%a) eq &dump($r);
104 eval { $r = fd_retrieve(::OUT); };
105 print "not " unless $@;
108 close OUT or die "Could not close: $!";
109 END { 1 while unlink 'store' }