3 # $Id: freeze.t,v 1.0.1.1 2001/07/01 11:25:16 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the same terms as Perl 5, as specified
8 # in the README file that comes with the distribution.
11 # Revision 1.0.1.1 2001/07/01 11:25:16 ram
12 # patch12: added test cases for mem corruption during thaw()
14 # Revision 1.0 2000/09/01 19:40:41 ram
15 # Baseline for first official release.
24 require Config; import Config;
25 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
26 print "1..0 # Skip: Storable was not built\n";
29 require 'lib/st-dump.pl';
33 use Storable qw(freeze nfreeze thaw);
45 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
46 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5, $d, \$d, \$e, $e,
47 $b, \$a, $a, $c, \$c, \%a);
49 print "not " unless defined ($f1 = freeze(\@a));
56 print "not " unless defined $root;
62 print "not " unless $got eq $dumped;
65 package FOO; @ISA = qw(Storable);
69 $self->{key} = \%main::a;
76 print "not " unless $f2 = $foo->freeze;
79 print "not " unless $f3 = $foo->nfreeze;
83 print "not " unless defined $root3;
86 print "not " unless &dump($foo) eq &dump($root3);
90 print "not " unless &dump($foo) eq &dump($root);
93 print "not " unless &dump($root3) eq &dump($root);
96 $other = freeze($root);
97 print "not " unless length($other) == length($f2);
100 $root2 = thaw($other);
101 print "not " unless &dump($root2) eq &dump($root);
108 'SELECT table_name, table_owner, num_rows FROM iitables
109 where table_owner != \'$ingres\' and table_owner != \'DBA\''
114 print "not " unless $VAR2->[3] eq $VAR1->[3];
117 # Test the workaround for LVALUE bug in perl 5.004_04 -- from Gisle Aas
118 sub foo { $_[0] = 1 }
121 eval { freeze($foo) };
125 # Test cleanup bug found by Claudio Garcia -- RAM, 08/06/2001
126 my $thaw_me = 'asdasdasdasd';
129 my $thawed = thaw $thaw_me;
133 my %to_be_frozen = (foo => 'bar');
136 $frozen = freeze \%to_be_frozen;
141 eval { thaw $thaw_me };
142 eval { $frozen = freeze { foo => {} } };
145 thaw $frozen; # used to segfault here