Fix (comment) typo pointed out by Robin Barker
[p5sagit/p5-mst-13.2.git] / dist / Storable / t / retrieve.t
CommitLineData
7a6a85bf 1#!./perl
7a6a85bf 2#
3# Copyright (c) 1995-2000, Raphael Manfredi
4#
9e21b3d0 5# You may redistribute only under the same terms as Perl 5, as specified
6# in the README file that comes with the distribution.
7a6a85bf 7#
7a6a85bf 8
9sub BEGIN {
48c887dd 10 unshift @INC, 't';
9f233367 11 require Config; import Config;
0c384302 12 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
9f233367 13 print "1..0 # Skip: Storable was not built\n";
14 exit 0;
15 }
372cb964 16 require 'st-dump.pl';
7a6a85bf 17}
18
19
20use Storable qw(store retrieve nstore);
21
22print "1..14\n";
23
24$a = 'toto';
25$b = \$a;
26$c = bless {}, CLASS;
27$c->{attribute} = 'attrval';
28%a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
29@a = ('first', '', undef, 3, -4, -3.14159, 456, 4.5,
30 $b, \$a, $a, $c, \$c, \%a);
31
32print "not " unless defined store(\@a, 'store');
33print "ok 1\n";
34print "not " if Storable::last_op_in_netorder();
35print "ok 2\n";
36print "not " unless defined nstore(\@a, 'nstore');
37print "ok 3\n";
38print "not " unless Storable::last_op_in_netorder();
39print "ok 4\n";
40print "not " unless Storable::last_op_in_netorder();
41print "ok 5\n";
42
43$root = retrieve('store');
44print "not " unless defined $root;
45print "ok 6\n";
46print "not " if Storable::last_op_in_netorder();
47print "ok 7\n";
48
49$nroot = retrieve('nstore');
50print "not " unless defined $nroot;
51print "ok 8\n";
52print "not " unless Storable::last_op_in_netorder();
53print "ok 9\n";
54
55$d1 = &dump($root);
56print "ok 10\n";
57$d2 = &dump($nroot);
58print "ok 11\n";
59
60print "not " unless $d1 eq $d2;
61print "ok 12\n";
62
63# Make sure empty string is defined at retrieval time
64print "not " unless defined $root->[1];
65print "ok 13\n";
66print "not " if length $root->[1];
67print "ok 14\n";
68
29fc1735 69END { 1 while unlink('store', 'nstore') }