Do not try to load a feature bundle when doing "no VERSION"
[p5sagit/p5-mst-13.2.git] / dist / Storable / t / retrieve.t
1 #!./perl
2 #
3 #  Copyright (c) 1995-2000, Raphael Manfredi
4 #  
5 #  You may redistribute only under the same terms as Perl 5, as specified
6 #  in the README file that comes with the distribution.
7 #
8
9 sub BEGIN {
10     unshift @INC, 't';
11     require Config; import Config;
12     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
13         print "1..0 # Skip: Storable was not built\n";
14         exit 0;
15     }
16     require 'st-dump.pl';
17 }
18
19
20 use Storable qw(store retrieve nstore);
21
22 print "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
32 print "not " unless defined store(\@a, 'store');
33 print "ok 1\n";
34 print "not " if Storable::last_op_in_netorder();
35 print "ok 2\n";
36 print "not " unless defined nstore(\@a, 'nstore');
37 print "ok 3\n";
38 print "not " unless Storable::last_op_in_netorder();
39 print "ok 4\n";
40 print "not " unless Storable::last_op_in_netorder();
41 print "ok 5\n";
42
43 $root = retrieve('store');
44 print "not " unless defined $root;
45 print "ok 6\n";
46 print "not " if Storable::last_op_in_netorder();
47 print "ok 7\n";
48
49 $nroot = retrieve('nstore');
50 print "not " unless defined $nroot;
51 print "ok 8\n";
52 print "not " unless Storable::last_op_in_netorder();
53 print "ok 9\n";
54
55 $d1 = &dump($root);
56 print "ok 10\n";
57 $d2 = &dump($nroot);
58 print "ok 11\n";
59
60 print "not " unless $d1 eq $d2; 
61 print "ok 12\n";
62
63 # Make sure empty string is defined at retrieval time
64 print "not " unless defined $root->[1];
65 print "ok 13\n";
66 print "not " if length $root->[1];
67 print "ok 14\n";
68
69 END { 1 while unlink('store', 'nstore') }