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.
11 # Revision 1.0 2000/09/01 19:40:42 ram
12 # Baseline for first official release.
18 @INC = ('.', '../lib', '../ext/Storable/t');
22 require Config; import Config;
23 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
24 print "1..0 # Skip: Storable was not built\n";
30 use Storable qw(store retrieve store_fd nstore_fd fd_retrieve);
37 $c->{attribute} = 'attrval';
38 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
39 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
40 $b, \$a, $a, $c, \$c, \%a);
42 print "not " unless defined store(\@a, 'store');
48 $root = retrieve('store');
49 print "not " unless defined $root;
55 print "not " unless $got eq $dumped;
58 1 while unlink 'store';
60 package FOO; @ISA = qw(Storable);
64 $self->{key} = \%main::a;
71 print "not " unless $foo->store('store');
74 print "not " unless open(OUT, '>>store');
78 print "not " unless defined store_fd(\@a, ::OUT);
80 print "not " unless defined nstore_fd($foo, ::OUT);
82 print "not " unless defined nstore_fd(\%a, ::OUT);
85 print "not " unless close(OUT);
88 print "not " unless open(OUT, 'store');
91 $r = fd_retrieve(::OUT);
92 print "not " unless defined $r;
94 print "not " unless &dump($foo) eq &dump($r);
97 $r = fd_retrieve(::OUT);
98 print "not " unless defined $r;
100 print "not " unless &dump(\@a) eq &dump($r);
103 $r = fd_retrieve(main::OUT);
104 print "not " unless defined $r;
106 print "not " unless &dump($foo) eq &dump($r);
109 $r = fd_retrieve(::OUT);
110 print "not " unless defined $r;
112 print "not " unless &dump(\%a) eq &dump($r);
115 eval { $r = fd_retrieve(::OUT); };
116 print "not " unless $@;
119 close OUT or die "Could not close: $!";
120 END { 1 while unlink 'store' }