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.
22 require Config; import Config;
23 if ($Config{'extensions'} !~ /\bStorable\b/) {
24 print "1..0 # Skip: Storable was not built\n";
27 require 'lib/st-dump.pl';
31 use Storable qw(freeze nfreeze thaw);
43 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
44 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5, $d, \$d, \$e, $e,
45 $b, \$a, $a, $c, \$c, \%a);
47 print "not " unless defined ($f1 = freeze(\@a));
54 print "not " unless defined $root;
60 print "not " unless $got eq $dumped;
63 package FOO; @ISA = qw(Storable);
67 $self->{key} = \%main::a;
74 print "not " unless $f2 = $foo->freeze;
77 print "not " unless $f3 = $foo->nfreeze;
81 print "not " unless defined $root3;
84 print "not " unless &dump($foo) eq &dump($root3);
88 print "not " unless &dump($foo) eq &dump($root);
91 print "not " unless &dump($root3) eq &dump($root);
94 $other = freeze($root);
95 print "not " unless length($other) == length($f2);
98 $root2 = thaw($other);
99 print "not " unless &dump($root2) eq &dump($root);
106 'SELECT table_name, table_owner, num_rows FROM iitables
107 where table_owner != \'$ingres\' and table_owner != \'DBA\''
112 print "not " unless $VAR2->[3] eq $VAR1->[3];
115 # Test the workaround for LVALUE bug in perl 5.004_04 -- from Gisle Aas
116 sub foo { $_[0] = 1 }
119 eval { freeze($foo) };
123 # Test cleanup bug found by Claudio Garcia -- RAM, 08/06/2001
124 my $thaw_me = 'asdasdasdasd';
127 my $thawed = thaw $thaw_me;
131 my %to_be_frozen = (foo => 'bar');
134 $frozen = freeze \%to_be_frozen;
139 eval { thaw $thaw_me };
140 eval { $frozen = freeze { foo => {} } };
143 thaw $frozen; # used to segfault here