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