Commit | Line | Data |
---|---|---|
7a6a85bf RG |
1 | #!./perl |
2 | ||
9e21b3d0 | 3 | # $Id: retrieve.t,v 1.0 2000/09/01 19:40:42 ram Exp $ |
7a6a85bf RG |
4 | # |
5 | # Copyright (c) 1995-2000, Raphael Manfredi | |
6 | # | |
9e21b3d0 JH |
7 | # You may redistribute only under the same terms as Perl 5, as specified |
8 | # in the README file that comes with the distribution. | |
7a6a85bf RG |
9 | # |
10 | # $Log: retrieve.t,v $ | |
9e21b3d0 JH |
11 | # Revision 1.0 2000/09/01 19:40:42 ram |
12 | # Baseline for first official release. | |
7a6a85bf RG |
13 | # |
14 | ||
15 | sub BEGIN { | |
16 | chdir('t') if -d 't'; | |
20822f61 MG |
17 | @INC = '.'; |
18 | push @INC, '../lib'; | |
9f233367 PP |
19 | require Config; import Config; |
20 | if ($Config{'extensions'} !~ /\bStorable\b/) { | |
21 | print "1..0 # Skip: Storable was not built\n"; | |
22 | exit 0; | |
23 | } | |
7a6a85bf RG |
24 | require 'lib/st-dump.pl'; |
25 | } | |
26 | ||
27 | ||
28 | use Storable qw(store retrieve nstore); | |
29 | ||
30 | print "1..14\n"; | |
31 | ||
32 | $a = 'toto'; | |
33 | $b = \$a; | |
34 | $c = bless {}, CLASS; | |
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); | |
39 | ||
40 | print "not " unless defined store(\@a, 'store'); | |
41 | print "ok 1\n"; | |
42 | print "not " if Storable::last_op_in_netorder(); | |
43 | print "ok 2\n"; | |
44 | print "not " unless defined nstore(\@a, 'nstore'); | |
45 | print "ok 3\n"; | |
46 | print "not " unless Storable::last_op_in_netorder(); | |
47 | print "ok 4\n"; | |
48 | print "not " unless Storable::last_op_in_netorder(); | |
49 | print "ok 5\n"; | |
50 | ||
51 | $root = retrieve('store'); | |
52 | print "not " unless defined $root; | |
53 | print "ok 6\n"; | |
54 | print "not " if Storable::last_op_in_netorder(); | |
55 | print "ok 7\n"; | |
56 | ||
57 | $nroot = retrieve('nstore'); | |
58 | print "not " unless defined $nroot; | |
59 | print "ok 8\n"; | |
60 | print "not " unless Storable::last_op_in_netorder(); | |
61 | print "ok 9\n"; | |
62 | ||
63 | $d1 = &dump($root); | |
64 | print "ok 10\n"; | |
65 | $d2 = &dump($nroot); | |
66 | print "ok 11\n"; | |
67 | ||
68 | print "not " unless $d1 eq $d2; | |
69 | print "ok 12\n"; | |
70 | ||
71 | # Make sure empty string is defined at retrieval time | |
72 | print "not " unless defined $root->[1]; | |
73 | print "ok 13\n"; | |
74 | print "not " if length $root->[1]; | |
75 | print "ok 14\n"; | |
76 | ||
29fc1735 | 77 | END { 1 while unlink('store', 'nstore') } |
7a6a85bf | 78 |