ExtUtils::MakeMaker 5.92_01 -> 5.94_02
[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#
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
15sub 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
30use Storable qw(store retrieve nstore);
31
32print "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
42print "not " unless defined store(\@a, 'store');
43print "ok 1\n";
44print "not " if Storable::last_op_in_netorder();
45print "ok 2\n";
46print "not " unless defined nstore(\@a, 'nstore');
47print "ok 3\n";
48print "not " unless Storable::last_op_in_netorder();
49print "ok 4\n";
50print "not " unless Storable::last_op_in_netorder();
51print "ok 5\n";
52
53$root = retrieve('store');
54print "not " unless defined $root;
55print "ok 6\n";
56print "not " if Storable::last_op_in_netorder();
57print "ok 7\n";
58
59$nroot = retrieve('nstore');
60print "not " unless defined $nroot;
61print "ok 8\n";
62print "not " unless Storable::last_op_in_netorder();
63print "ok 9\n";
64
65$d1 = &dump($root);
66print "ok 10\n";
67$d2 = &dump($nroot);
68print "ok 11\n";
69
70print "not " unless $d1 eq $d2;
71print "ok 12\n";
72
73# Make sure empty string is defined at retrieval time
74print "not " unless defined $root->[1];
75print "ok 13\n";
76print "not " if length $root->[1];
77print "ok 14\n";
78
29fc1735 79END { 1 while unlink('store', 'nstore') }
7a6a85bf 80