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.
21 @INC = ('.', '../lib', '../ext/Storable/t');
25 require Config; import Config;
26 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
27 print "1..0 # Skip: Storable was not built\n";
34 use Storable qw(freeze nfreeze thaw);
46 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
47 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5, $d, \$d, \$e, $e,
48 $b, \$a, $a, $c, \$c, \%a);
50 print "not " unless defined ($f1 = freeze(\@a));
57 print "not " unless defined $root;
63 print "not " unless $got eq $dumped;
66 package FOO; @ISA = qw(Storable);
70 $self->{key} = \%main::a;
77 print "not " unless $f2 = $foo->freeze;
80 print "not " unless $f3 = $foo->nfreeze;
84 print "not " unless defined $root3;
87 print "not " unless &dump($foo) eq &dump($root3);
91 print "not " unless &dump($foo) eq &dump($root);
94 print "not " unless &dump($root3) eq &dump($root);
97 $other = freeze($root);
98 print "not " unless length($other) == length($f2);
101 $root2 = thaw($other);
102 print "not " unless &dump($root2) eq &dump($root);
109 'SELECT table_name, table_owner, num_rows FROM iitables
110 where table_owner != \'$ingres\' and table_owner != \'DBA\''
115 print "not " unless $VAR2->[3] eq $VAR1->[3];
118 # Test the workaround for LVALUE bug in perl 5.004_04 -- from Gisle Aas
119 sub foo { $_[0] = 1 }
122 eval { freeze($foo) };
126 # Test cleanup bug found by Claudio Garcia -- RAM, 08/06/2001
127 my $thaw_me = 'asdasdasdasd';
130 my $thawed = thaw $thaw_me;
134 my %to_be_frozen = (foo => 'bar');
137 $frozen = freeze \%to_be_frozen;
142 eval { thaw $thaw_me };
143 eval { $frozen = freeze { foo => {} } };
146 thaw $frozen; # used to segfault here