3 # Copyright (c) 1995-2000, Raphael Manfredi
5 # You may redistribute only under the same terms as Perl 5, as specified
6 # in the README file that comes with the distribution.
11 unshift @INC, 't/compat' if $] < 5.006002;
12 require Config; import Config;
13 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
14 print "1..0 # Skip: Storable was not built\n";
20 use Storable qw(freeze nfreeze thaw);
22 use Test::More tests => 21;
32 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
33 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5, $d, \$d, \$e, $e,
34 $b, \$a, $a, $c, \$c, \%a);
50 package FOO; @ISA = qw(Storable);
54 $self->{key} = \%main::a;
61 my $f2 = $foo->freeze;
64 my $f3 = $foo->nfreeze;
70 is(&dump($foo), &dump($root3));
73 is(&dump($foo), &dump($root));
75 is(&dump($root3), &dump($root));
77 $other = freeze($root);
78 is(length$other, length $f2);
80 $root2 = thaw($other);
81 is(&dump($root2), &dump($root));
87 'SELECT table_name, table_owner, num_rows FROM iitables
88 where table_owner != \'$ingres\' and table_owner != \'DBA\''
93 is($VAR2->[3], $VAR1->[3]);
95 # Test the workaround for LVALUE bug in perl 5.004_04 -- from Gisle Aas
99 eval { freeze($foo) };
102 # Test cleanup bug found by Claudio Garcia -- RAM, 08/06/2001
103 my $thaw_me = 'asdasdasdasd';
106 my $thawed = thaw $thaw_me;
110 my %to_be_frozen = (foo => 'bar');
113 $frozen = freeze \%to_be_frozen;
118 eval { thaw $thaw_me };
119 eval { $frozen = freeze { foo => {} } };
122 thaw $frozen; # used to segfault here
123 pass("Didn't segfault");
126 skip 'no av_exists', 2 unless $] >= 5.006;
129 $a = []; $#$a = 2; $a->[1] = undef;
131 @a = map { ~~ exists $a->[$_] } 0 .. $#$a;
132 @b = map { ~~ exists $b->[$_] } 0 .. $#$b;