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.
14 @INC = ('.', '../lib', '../ext/Storable/t');
18 require Config; import Config;
19 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
20 print "1..0 # Skip: Storable was not built\n";
27 use Storable qw(freeze nfreeze thaw);
39 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
40 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5, $d, \$d, \$e, $e,
41 $b, \$a, $a, $c, \$c, \%a);
43 print "not " unless defined ($f1 = freeze(\@a));
50 print "not " unless defined $root;
56 print "not " unless $got eq $dumped;
59 package FOO; @ISA = qw(Storable);
63 $self->{key} = \%main::a;
70 print "not " unless $f2 = $foo->freeze;
73 print "not " unless $f3 = $foo->nfreeze;
77 print "not " unless defined $root3;
80 print "not " unless &dump($foo) eq &dump($root3);
84 print "not " unless &dump($foo) eq &dump($root);
87 print "not " unless &dump($root3) eq &dump($root);
90 $other = freeze($root);
91 print "not " unless length($other) == length($f2);
94 $root2 = thaw($other);
95 print "not " unless &dump($root2) eq &dump($root);
102 'SELECT table_name, table_owner, num_rows FROM iitables
103 where table_owner != \'$ingres\' and table_owner != \'DBA\''
108 print "not " unless $VAR2->[3] eq $VAR1->[3];
111 # Test the workaround for LVALUE bug in perl 5.004_04 -- from Gisle Aas
112 sub foo { $_[0] = 1 }
115 eval { freeze($foo) };
119 # Test cleanup bug found by Claudio Garcia -- RAM, 08/06/2001
120 my $thaw_me = 'asdasdasdasd';
123 my $thawed = thaw $thaw_me;
127 my %to_be_frozen = (foo => 'bar');
130 $frozen = freeze \%to_be_frozen;
135 eval { thaw $thaw_me };
136 eval { $frozen = freeze { foo => {} } };
139 thaw $frozen; # used to segfault here