This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add Storable 0.7.2 from Raphael Manfredi,
[perl5.git] / t / lib / st-retrieve.t
CommitLineData
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
15sub BEGIN {
16 chdir('t') if -d 't';
17 unshift @INC, '../lib';
18 require 'lib/st-dump.pl';
19}
20
21
22use Storable qw(store retrieve nstore);
23
24print "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
34print "not " unless defined store(\@a, 'store');
35print "ok 1\n";
36print "not " if Storable::last_op_in_netorder();
37print "ok 2\n";
38print "not " unless defined nstore(\@a, 'nstore');
39print "ok 3\n";
40print "not " unless Storable::last_op_in_netorder();
41print "ok 4\n";
42print "not " unless Storable::last_op_in_netorder();
43print "ok 5\n";
44
45$root = retrieve('store');
46print "not " unless defined $root;
47print "ok 6\n";
48print "not " if Storable::last_op_in_netorder();
49print "ok 7\n";
50
51$nroot = retrieve('nstore');
52print "not " unless defined $nroot;
53print "ok 8\n";
54print "not " unless Storable::last_op_in_netorder();
55print "ok 9\n";
56
57$d1 = &dump($root);
58print "ok 10\n";
59$d2 = &dump($nroot);
60print "ok 11\n";
61
62print "not " unless $d1 eq $d2;
63print "ok 12\n";
64
65# Make sure empty string is defined at retrieval time
66print "not " unless defined $root->[1];
67print "ok 13\n";
68print "not " if length $root->[1];
69print "ok 14\n";
70
71END { unlink 'store', 'nstore' }
72