Commit | Line | Data |
---|---|---|
7a6a85bf RG |
1 | #!./perl |
2 | ||
3 | # $Id: retrieve.t,v 0.7 2000/08/03 22:04:45 ram Exp $ | |
4 | # | |
5 | # Copyright (c) 1995-2000, Raphael Manfredi | |
6 | # | |
7 | # You may redistribute only under the terms of the Artistic License, | |
8 | # as specified in the README file that comes with the distribution. | |
9 | # | |
10 | # $Log: retrieve.t,v $ | |
11 | # Revision 0.7 2000/08/03 22:04:45 ram | |
12 | # Baseline for second beta release. | |
13 | # | |
14 | ||
15 | sub BEGIN { | |
16 | chdir('t') if -d 't'; | |
17 | unshift @INC, '../lib'; | |
18 | require 'lib/st-dump.pl'; | |
19 | } | |
20 | ||
21 | ||
22 | use Storable qw(store retrieve nstore); | |
23 | ||
24 | print "1..14\n"; | |
25 | ||
26 | $a = 'toto'; | |
27 | $b = \$a; | |
28 | $c = bless {}, CLASS; | |
29 | $c->{attribute} = 'attrval'; | |
30 | %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c); | |
31 | @a = ('first', '', undef, 3, -4, -3.14159, 456, 4.5, | |
32 | $b, \$a, $a, $c, \$c, \%a); | |
33 | ||
34 | print "not " unless defined store(\@a, 'store'); | |
35 | print "ok 1\n"; | |
36 | print "not " if Storable::last_op_in_netorder(); | |
37 | print "ok 2\n"; | |
38 | print "not " unless defined nstore(\@a, 'nstore'); | |
39 | print "ok 3\n"; | |
40 | print "not " unless Storable::last_op_in_netorder(); | |
41 | print "ok 4\n"; | |
42 | print "not " unless Storable::last_op_in_netorder(); | |
43 | print "ok 5\n"; | |
44 | ||
45 | $root = retrieve('store'); | |
46 | print "not " unless defined $root; | |
47 | print "ok 6\n"; | |
48 | print "not " if Storable::last_op_in_netorder(); | |
49 | print "ok 7\n"; | |
50 | ||
51 | $nroot = retrieve('nstore'); | |
52 | print "not " unless defined $nroot; | |
53 | print "ok 8\n"; | |
54 | print "not " unless Storable::last_op_in_netorder(); | |
55 | print "ok 9\n"; | |
56 | ||
57 | $d1 = &dump($root); | |
58 | print "ok 10\n"; | |
59 | $d2 = &dump($nroot); | |
60 | print "ok 11\n"; | |
61 | ||
62 | print "not " unless $d1 eq $d2; | |
63 | print "ok 12\n"; | |
64 | ||
65 | # Make sure empty string is defined at retrieval time | |
66 | print "not " unless defined $root->[1]; | |
67 | print "ok 13\n"; | |
68 | print "not " if length $root->[1]; | |
69 | print "ok 14\n"; | |
70 | ||
71 | END { unlink 'store', 'nstore' } | |
72 |