6 use Test::More tests => 6;
8 use t::common qw( new_fh );
10 use_ok( 'DBM::Deep' );
12 my ($fh, $filename) = new_fh();
15 # test a corrupted file
17 open FH, ">$filename";
21 DBM::Deep->new( $filename );
22 } qr/DBM::Deep: Old file version found/, "Fail if there's a bad header";
25 my ($fh, $filename) = new_fh();
27 tie %hash, 'DBM::Deep', $filename;
32 tie @array, 'DBM::Deep', $filename;
33 } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie a hash file with an array";
36 DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY )
37 } qr/DBM::Deep: File type mismatch/, "Fail if we try and open a hash file with an array";
41 my ($fh, $filename) = new_fh();
43 tie @array, 'DBM::Deep', $filename;
48 tie %hash, 'DBM::Deep', $filename;
49 } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie an array file with a hash";
52 DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_HASH )
53 } qr/DBM::Deep: File type mismatch/, "Fail if we try and open an array file with a hash";