Commit | Line | Data |
7a6a85bf |
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'; |
9f233367 |
17 | require Config; import Config; |
18 | if ($Config{'extensions'} !~ /\bStorable\b/) { |
19 | print "1..0 # Skip: Storable was not built\n"; |
20 | exit 0; |
21 | } |
7a6a85bf |
22 | unshift @INC, '../lib'; |
23 | require 'lib/st-dump.pl'; |
24 | } |
25 | |
26 | |
27 | use Storable qw(store retrieve nstore); |
28 | |
29 | print "1..14\n"; |
30 | |
31 | $a = 'toto'; |
32 | $b = \$a; |
33 | $c = bless {}, CLASS; |
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); |
38 | |
39 | print "not " unless defined store(\@a, 'store'); |
40 | print "ok 1\n"; |
41 | print "not " if Storable::last_op_in_netorder(); |
42 | print "ok 2\n"; |
43 | print "not " unless defined nstore(\@a, 'nstore'); |
44 | print "ok 3\n"; |
45 | print "not " unless Storable::last_op_in_netorder(); |
46 | print "ok 4\n"; |
47 | print "not " unless Storable::last_op_in_netorder(); |
48 | print "ok 5\n"; |
49 | |
50 | $root = retrieve('store'); |
51 | print "not " unless defined $root; |
52 | print "ok 6\n"; |
53 | print "not " if Storable::last_op_in_netorder(); |
54 | print "ok 7\n"; |
55 | |
56 | $nroot = retrieve('nstore'); |
57 | print "not " unless defined $nroot; |
58 | print "ok 8\n"; |
59 | print "not " unless Storable::last_op_in_netorder(); |
60 | print "ok 9\n"; |
61 | |
62 | $d1 = &dump($root); |
63 | print "ok 10\n"; |
64 | $d2 = &dump($nroot); |
65 | print "ok 11\n"; |
66 | |
67 | print "not " unless $d1 eq $d2; |
68 | print "ok 12\n"; |
69 | |
70 | # Make sure empty string is defined at retrieval time |
71 | print "not " unless defined $root->[1]; |
72 | print "ok 13\n"; |
73 | print "not " if length $root->[1]; |
74 | print "ok 14\n"; |
75 | |
76 | END { unlink 'store', 'nstore' } |
77 | |