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.
19 require Config; import Config;
20 if ($Config{'extensions'} !~ /\bStorable\b/) {
21 print "1..0 # Skip: Storable was not built\n";
24 require 'lib/st-dump.pl';
27 use Storable qw(store retrieve store_fd nstore_fd fd_retrieve);
34 $c->{attribute} = 'attrval';
35 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
36 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
37 $b, \$a, $a, $c, \$c, \%a);
39 print "not " unless defined store(\@a, 'store');
45 $root = retrieve('store');
46 print "not " unless defined $root;
52 print "not " unless $got eq $dumped;
55 1 while unlink 'store';
57 package FOO; @ISA = qw(Storable);
61 $self->{key} = \%main::a;
68 print "not " unless $foo->store('store');
71 print "not " unless open(OUT, '>>store');
75 print "not " unless defined store_fd(\@a, ::OUT);
77 print "not " unless defined nstore_fd($foo, ::OUT);
79 print "not " unless defined nstore_fd(\%a, ::OUT);
82 print "not " unless close(OUT);
85 print "not " unless open(OUT, 'store');
88 $r = fd_retrieve(::OUT);
89 print "not " unless defined $r;
91 print "not " unless &dump($foo) eq &dump($r);
94 $r = fd_retrieve(::OUT);
95 print "not " unless defined $r;
97 print "not " unless &dump(\@a) eq &dump($r);
100 $r = fd_retrieve(main::OUT);
101 print "not " unless defined $r;
103 print "not " unless &dump($foo) eq &dump($r);
106 $r = fd_retrieve(::OUT);
107 print "not " unless defined $r;
109 print "not " unless &dump(\%a) eq &dump($r);
112 eval { $r = fd_retrieve(::OUT); };
113 print "not " unless $@;
116 close OUT or die "Could not close: $!";
117 END { 1 while unlink 'store' }