#!./perl
#
# Copyright (c) 1995-2000, Raphael Manfredi
#
# You may redistribute only under the same terms as Perl 5, as specified
# in the README file that comes with the distribution.
#
chdir('t') if -d 't';
} else {
}
print "1..0 # Skip: Storable was not built\n";
exit 0;
}
}
sub ok;
%::immortals
= (u => \undef,
'y' => \(1 == 1),
n => \(1 == 0)
);
my $test = 12;
print "1..$tests\n";
sub STORABLE_freeze {
my $self = shift;
}
sub STORABLE_thaw {
my $self = shift;
my $cloning = shift;
}
# Still less than 256 bytes, so long classname logic not fully exercised
# Wait until Perl removes the restriction on identifier lengths.
eval <<EOC;
package $name;
\@ISA = ("SHORT_NAME");
EOC
die $@ if $@;
eval <<EOC;
package ${name}_WITH_HOOK;
\@ISA = ("SHORT_NAME_WITH_HOOK");
EOC
# Construct a pool of objects
my @pool;
for (my $i = 0; $i < 10; $i++) {
}
ok 3, 1;
my $y = thaw $x;
my $good = 1;
for (my $i = 0; $i < 10; $i++) {
}
{
my $x = freeze $blessed_ref;
my $y = thaw $x;
ok 12, $$$y->[0] == 1;
}
sub STORABLE_freeze {
# Some reference some number of times.
my $self = shift;
}
sub STORABLE_thaw {
my $self = shift;
my $cloning = shift;
my $fail;
}
}
# $Storable::DEBUGME = 1;
my $count;
my $immortal;
my $t = thaw $f;
}
}
# Test automatic require of packages to find thaw hook.
$loaded_count = 0;
$thawed_count = 0;
sub make {
bless [];
}
sub STORABLE_freeze {
my $self = shift;
return '';
}
ok ++$test, $HAS_HOOK::loaded_count == 0;
ok ++$test, $HAS_HOOK::thawed_count == 0;
my $t = thaw $f;
ok ++$test, $HAS_HOOK::loaded_count == 1;
ok ++$test, $HAS_HOOK::thawed_count == 1;
# Can't do this because the method is still cached by UNIVERSAL::can
# delete $INC{"HAS_HOOK.pm"};
# undef &HAS_HOOK::STORABLE_thaw;
#
# warn HAS_HOOK->can('STORABLE_thaw');
# $t = thaw $f;
# ok ++$test, $HAS_HOOK::loaded_count == 2;
# ok ++$test, $HAS_HOOK::thawed_count == 2;
# ok ++$test, $t;
# ok ++$test, ref $t eq 'HAS_HOOK';