3 # $Id: store.t,v 0.7 2000/08/03 22:04:45 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the terms of the Artistic License,
8 # as specified in the README file that comes with the distribution.
11 # Revision 0.7 2000/08/03 22:04:45 ram
12 # Baseline for second beta 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';
28 use Storable qw(store retrieve store_fd nstore_fd retrieve_fd);
35 $c->{attribute} = 'attrval';
36 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
37 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
38 $b, \$a, $a, $c, \$c, \%a);
40 print "not " unless defined store(\@a, 'store');
46 $root = retrieve('store');
47 print "not " unless defined $root;
53 print "not " unless $got eq $dumped;
56 1 while unlink 'store';
58 package FOO; @ISA = qw(Storable);
62 $self->{key} = \%main::a;
69 print "not " unless $foo->store('store');
72 print "not " unless open(OUT, '>>store');
76 print "not " unless defined store_fd(\@a, ::OUT);
78 print "not " unless defined nstore_fd($foo, ::OUT);
80 print "not " unless defined nstore_fd(\%a, ::OUT);
83 print "not " unless close(OUT);
86 print "not " unless open(OUT, 'store');
89 $r = retrieve_fd(::OUT);
90 print "not " unless defined $r;
92 print "not " unless &dump($foo) eq &dump($r);
95 $r = retrieve_fd(::OUT);
96 print "not " unless defined $r;
98 print "not " unless &dump(\@a) eq &dump($r);
101 $r = retrieve_fd(main::OUT);
102 print "not " unless defined $r;
104 print "not " unless &dump($foo) eq &dump($r);
107 $r = retrieve_fd(::OUT);
108 print "not " unless defined $r;
110 print "not " unless &dump(\%a) eq &dump($r);
113 eval { $r = retrieve_fd(::OUT); };
114 print "not " unless $@;
118 END { 1 while unlink 'store' }