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.
21 require Config; import Config;
22 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
23 print "1..0 # Skip: Storable was not built\n";
26 require 'lib/st-dump.pl';
29 use Storable qw(store retrieve store_fd nstore_fd fd_retrieve);
36 $c->{attribute} = 'attrval';
37 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
38 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
39 $b, \$a, $a, $c, \$c, \%a);
41 print "not " unless defined store(\@a, 'store');
47 $root = retrieve('store');
48 print "not " unless defined $root;
54 print "not " unless $got eq $dumped;
57 1 while unlink 'store';
59 package FOO; @ISA = qw(Storable);
63 $self->{key} = \%main::a;
70 print "not " unless $foo->store('store');
73 print "not " unless open(OUT, '>>store');
77 print "not " unless defined store_fd(\@a, ::OUT);
79 print "not " unless defined nstore_fd($foo, ::OUT);
81 print "not " unless defined nstore_fd(\%a, ::OUT);
84 print "not " unless close(OUT);
87 print "not " unless open(OUT, 'store');
90 $r = fd_retrieve(::OUT);
91 print "not " unless defined $r;
93 print "not " unless &dump($foo) eq &dump($r);
96 $r = fd_retrieve(::OUT);
97 print "not " unless defined $r;
99 print "not " unless &dump(\@a) eq &dump($r);
102 $r = fd_retrieve(main::OUT);
103 print "not " unless defined $r;
105 print "not " unless &dump($foo) eq &dump($r);
108 $r = fd_retrieve(::OUT);
109 print "not " unless defined $r;
111 print "not " unless &dump(\%a) eq &dump($r);
114 eval { $r = fd_retrieve(::OUT); };
115 print "not " unless $@;
118 close OUT or die "Could not close: $!";
119 END { 1 while unlink 'store' }