6 use Test::More tests => 6;
8 use File::Temp qw( tempfile tempdir );
9 use Fcntl qw( :flock );
11 use_ok( 'DBM::Deep' );
13 my $dir = tempdir( CLEANUP => 1 );
14 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
18 # test a corrupted file
20 open FH, ">$filename";
24 DBM::Deep->new( $filename );
25 } qr/DBM::Deep: Corrupted file, no master index record/, "Fail if there's no master index record";
28 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
31 tie %hash, 'DBM::Deep', $filename;
36 tie @array, 'DBM::Deep', $filename;
37 } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie a hash file with an array";
40 DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY )
41 } qr/DBM::Deep: File type mismatch/, "Fail if we try and open a hash file with an array";
45 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
48 tie @array, 'DBM::Deep', $filename;
53 tie %hash, 'DBM::Deep', $filename;
54 } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie an array file with a hash";
57 DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_HASH )
58 } qr/DBM::Deep: File type mismatch/, "Fail if we try and open an array file with a hash";