5 use Test::More tests => 11;
7 use t::common qw( new_fh );
12 # testing the various modes of opening a file
15 my ($fh, $filename) = new_fh();
17 my $db = tie %hash, 'DBM::Deep', $filename;
19 ok(1, "Tied an hash with an array for params" );
23 my ($fh, $filename) = new_fh();
25 my $db = tie %hash, 'DBM::Deep', {
29 ok(1, "Tied a hash with a hashref for params" );
33 my ($fh, $filename) = new_fh();
35 my $db = tie @array, 'DBM::Deep', $filename;
37 ok(1, "Tied an array with an array for params" );
39 is( $db->{type}, DBM::Deep->TYPE_ARRAY, "TIE_ARRAY sets the correct type" );
43 my ($fh, $filename) = new_fh();
45 my $db = tie @array, 'DBM::Deep', {
49 ok(1, "Tied an array with a hashref for params" );
51 is( $db->{type}, DBM::Deep->TYPE_ARRAY, "TIE_ARRAY sets the correct type" );
54 my ($fh, $filename) = new_fh();
56 tie my %hash, 'DBM::Deep', [ file => $filename ];
57 } qr/Not a hashref/, "Passing an arrayref to TIEHASH fails";
60 tie my @array, 'DBM::Deep', [ file => $filename ];
61 } qr/Not a hashref/, "Passing an arrayref to TIEARRAY fails";
64 tie my %hash, 'DBM::Deep', undef, file => $filename;
65 } qr/Odd number of parameters/, "Odd number of params to TIEHASH fails";
68 tie my @array, 'DBM::Deep', undef, file => $filename;
69 } qr/Odd number of parameters/, "Odd number of params to TIEARRAY fails";