#!./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;
print "1..33\n";
@x = ('a', 1);
sub STORABLE_freeze {
my $self = shift;
my $cloning = shift;
}
sub STORABLE_thaw {
my $self = shift;
my $cloning = shift;
my $a = thaw $x;
@$self = @$a;
}
@x = ('a', 1);
sub STORABLE_freeze {
my $self = shift;
return if $cloning;
}
sub STORABLE_thaw {
my $self = shift;
}
sub make {
return $self;
}
sub STORABLE_freeze {
my $self = shift;
my $r = \%copy;
}
sub STORABLE_thaw {
my $self = shift;
}
$MAX = 20;
$recursed = 0;
$hook_called = 0;
sub STORABLE_freeze {
my $self = shift;
$hook_called++;
}
sub STORABLE_thaw {
my $self = shift;
my $cloning = shift;
$recursed--;
}
ok 1, 1;
my $y = thaw $x;
ok 4, $y->[1] == 1;
ok 5, 1;
$y = thaw $x;
ok 6, 1;
my $ext = [1, 2];
ok 8, 1;
my $z = thaw $x;
$y = $z->[0];
ok 9, 1;
ok 13, 1;
ok 14, $OBJ_REAL2::recursed == $OBJ_REAL2::MAX;
ok 15, $OBJ_REAL2::hook_called == $OBJ_REAL2::MAX;
$y = thaw $x;
ok 16, 1;
ok 17, $OBJ_REAL2::recursed == 0;
ok 18, 1;
ok 20, $OBJ_REAL2::recursed == 0;
ok 21, $OBJ_REAL2::hook_called == 2 * $OBJ_REAL2::MAX;
ok 22, !Storable::is_storing;
ok 23, !Storable::is_retrieving;
#
# The following was a test-case that Salvador Ortiz Garcia <sog@msg.com.mx>
# sent me, along with a proposed fix.
#
sub new {
my $class = shift;
my $dat = shift;
}
sub new {
my $class = shift;
return bless {
a => 'dummy',
b => [
]
}, $class;
}
sub STORABLE_freeze {
}
sub STORABLE_thaw {
$self->{b} = $o;
}
#
# The following attempts to make sure blessed objects are blessed ASAP
# at retrieve time.
#
sub make {
return $self;
}
sub make {
my ($o) = @_;
$self->{o} = $o;
return $self;
}
sub STORABLE_freeze {
}
sub STORABLE_thaw {
}
sub make {
return $self;
}
#
# Is the reference count of the extra references returned from a
# STORABLE_freeze hook correct? [ID 20020601.005]
#
sub new {
return $self;
}
sub DESTROY {
my $self = shift;
}
sub new {
bless {}, $_[0];
}
sub STORABLE_freeze {
my $obj = shift;
}
$refcount_ok = 0;
ok 33, $refcount_ok == 1;