Backward portability from Dan Kogai.
[p5sagit/p5-mst-13.2.git] / ext / Storable / t / lock.t
1 #!./perl
2
3 # $Id: lock.t,v 1.0.1.4 2001/01/03 09:41:00 ram Exp $
4 #
5 #  @COPYRIGHT@
6 #
7 # $Log: lock.t,v $
8 # Revision 1.0.1.4  2001/01/03 09:41:00  ram
9 # patch7: use new CAN_FLOCK routine to determine whether to run tests
10 #
11 # Revision 1.0.1.3  2000/10/26 17:11:27  ram
12 # patch5: just check $^O, there's no need for the whole Config
13 #
14 # Revision 1.0.1.2  2000/10/23 18:03:07  ram
15 # patch4: protected calls to flock() for dos platform
16 #
17 # Revision 1.0.1.1  2000/09/28 21:44:06  ram
18 # patch2: created.
19 #
20 #
21
22 sub BEGIN {
23     if ($ENV{PERL_CORE}){
24         chdir('t') if -d 't';
25         @INC = '.'; 
26         push @INC, '../lib';
27     }
28     require Config; import Config;
29     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
30         print "1..0 # Skip: Storable was not built\n";
31         exit 0;
32     }
33
34     require 'lib/st-dump.pl';
35 }
36
37 sub ok;
38
39 use Storable qw(lock_store lock_retrieve);
40
41 unless (&Storable::CAN_FLOCK) {
42     print "1..0 # Skip: fcntl/flock emulation broken on this platform\n";
43         exit 0;
44 }
45
46 print "1..5\n";
47
48 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5);
49
50 #
51 # We're just ensuring things work, we're not validating locking.
52 #
53
54 ok 1, defined lock_store(\@a, 'store');
55 ok 2, $dumped = &dump(\@a);
56
57 $root = lock_retrieve('store');
58 ok 3, ref $root eq 'ARRAY';
59 ok 4, @a == @$root;
60 ok 5, &dump($root) eq $dumped; 
61
62 unlink 't/store';
63