Blame t/lock.t

Packit 14c646
#!./perl
Packit 14c646
#
Packit 14c646
#  Copyright (c) 1995-2000, Raphael Manfredi
Packit 14c646
#  
Packit 14c646
#  You may redistribute only under the same terms as Perl 5, as specified
Packit 14c646
#  in the README file that comes with the distribution.
Packit 14c646
#
Packit 14c646
Packit 14c646
sub BEGIN {
Packit 14c646
    unshift @INC, 't';
Packit 14c646
    unshift @INC, 't/compat' if $] < 5.006002;
Packit 14c646
    require Config; import Config;
Packit 14c646
    if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
Packit 14c646
        print "1..0 # Skip: Storable was not built\n";
Packit 14c646
        exit 0;
Packit 14c646
    }
Packit 14c646
Packit 14c646
    require 'st-dump.pl';
Packit 14c646
}
Packit 14c646
Packit 14c646
use Test::More;
Packit 14c646
use Storable qw(lock_store lock_retrieve);
Packit 14c646
Packit 14c646
unless (&Storable::CAN_FLOCK) {
Packit 14c646
    plan(skip_all => "fcntl/flock emulation broken on this platform");
Packit 14c646
}
Packit 14c646
Packit 14c646
plan(tests => 5);
Packit 14c646
Packit 14c646
@a = ('first', undef, 3, -4, -3.14159, 456, 4.5);
Packit 14c646
Packit 14c646
#
Packit 14c646
# We're just ensuring things work, we're not validating locking.
Packit 14c646
#
Packit 14c646
Packit 14c646
isnt(lock_store(\@a, "store$$"), undef);
Packit 14c646
my $dumped = &dump(\@a);
Packit 14c646
isnt($dumped, undef);
Packit 14c646
Packit 14c646
$root = lock_retrieve("store$$");
Packit 14c646
is(ref $root, 'ARRAY');
Packit 14c646
is(scalar @a, scalar @$root);
Packit 14c646
is(&dump($root), $dumped);
Packit 14c646
Packit 14c646
END { 1 while unlink "store$$" }
Packit 14c646