3 # $Id: store.t,v 1.0 2000/09/01 19:40:42 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the same terms as Perl 5, as specified
8 # in the README file that comes with the distribution.
14 @INC = ('.', '../lib', '../ext/Storable/t');
18 require Config; import Config;
19 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
20 print "1..0 # Skip: Storable was not built\n";
26 use Storable qw(store retrieve store_fd nstore_fd fd_retrieve);
33 $c->{attribute} = 'attrval';
34 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
35 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
36 $b, \$a, $a, $c, \$c, \%a);
38 print "not " unless defined store(\@a, 'store');
44 $root = retrieve('store');
45 print "not " unless defined $root;
51 print "not " unless $got eq $dumped;
54 1 while unlink 'store';
56 package FOO; @ISA = qw(Storable);
60 $self->{key} = \%main::a;
67 print "not " unless $foo->store('store');
70 print "not " unless open(OUT, '>>store');
74 print "not " unless defined store_fd(\@a, ::OUT);
76 print "not " unless defined nstore_fd($foo, ::OUT);
78 print "not " unless defined nstore_fd(\%a, ::OUT);
81 print "not " unless close(OUT);
84 print "not " unless open(OUT, 'store');
87 $r = fd_retrieve(::OUT);
88 print "not " unless defined $r;
90 print "not " unless &dump($foo) eq &dump($r);
93 $r = fd_retrieve(::OUT);
94 print "not " unless defined $r;
96 print "not " unless &dump(\@a) eq &dump($r);
99 $r = fd_retrieve(main::OUT);
100 print "not " unless defined $r;
102 print "not " unless &dump($foo) eq &dump($r);
105 $r = fd_retrieve(::OUT);
106 print "not " unless defined $r;
108 print "not " unless &dump(\%a) eq &dump($r);
111 eval { $r = fd_retrieve(::OUT); };
112 print "not " unless $@;
115 close OUT or die "Could not close: $!";
116 END { 1 while unlink 'store' }