Lots of spring cleaning. (No functional changes.)
[p5sagit/p5-mst-13.2.git] / ext / Storable / t / retrieve.t
CommitLineData
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#
7a6a85bf 10
11sub BEGIN {
0c384302 12 if ($ENV{PERL_CORE}){
13 chdir('t') if -d 't';
7dadce44 14 @INC = ('.', '../lib', '../ext/Storable/t');
372cb964 15 } else {
16 unshift @INC, 't';
0c384302 17 }
9f233367 18 require Config; import Config;
0c384302 19 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
9f233367 20 print "1..0 # Skip: Storable was not built\n";
21 exit 0;
22 }
372cb964 23 require 'st-dump.pl';
7a6a85bf 24}
25
26
27use Storable qw(store retrieve nstore);
28
29print "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
39print "not " unless defined store(\@a, 'store');
40print "ok 1\n";
41print "not " if Storable::last_op_in_netorder();
42print "ok 2\n";
43print "not " unless defined nstore(\@a, 'nstore');
44print "ok 3\n";
45print "not " unless Storable::last_op_in_netorder();
46print "ok 4\n";
47print "not " unless Storable::last_op_in_netorder();
48print "ok 5\n";
49
50$root = retrieve('store');
51print "not " unless defined $root;
52print "ok 6\n";
53print "not " if Storable::last_op_in_netorder();
54print "ok 7\n";
55
56$nroot = retrieve('nstore');
57print "not " unless defined $nroot;
58print "ok 8\n";
59print "not " unless Storable::last_op_in_netorder();
60print "ok 9\n";
61
62$d1 = &dump($root);
63print "ok 10\n";
64$d2 = &dump($nroot);
65print "ok 11\n";
66
67print "not " unless $d1 eq $d2;
68print "ok 12\n";
69
70# Make sure empty string is defined at retrieval time
71print "not " unless defined $root->[1];
72print "ok 13\n";
73print "not " if length $root->[1];
74print "ok 14\n";
75
29fc1735 76END { 1 while unlink('store', 'nstore') }