5 use Test::More tests => 11;
11 # testing the various modes of opening a file
16 my $db = tie %hash, 'DBM::Deep', 't/test.db';
19 print "ERROR: " . $db->error();
23 else { ok(1, "Tied an hash with an array for params" ); }
29 my $db = tie %hash, 'DBM::Deep', {
34 print "ERROR: " . $db->error();
38 else { ok(1, "Tied a hash with a hashref for params" ); }
44 my $db = tie @array, 'DBM::Deep', 't/test.db';
47 print "ERROR: " . $db->error();
51 else { ok(1, "Tied an array with an array for params" ); }
53 is( $db->{type}, DBM::Deep->TYPE_ARRAY, "TIE_ARRAY sets the correct type" );
59 my $db = tie @array, 'DBM::Deep', {
64 print "ERROR: " . $db->error();
68 else { ok(1, "Tied an array with a hashref for params" ); }
70 is( $db->{type}, DBM::Deep->TYPE_ARRAY, "TIE_ARRAY sets the correct type" );
75 tie my %hash, 'DBM::Deep', [ file => 't/test.db' ];
76 } qr/Not a hashref/, "Passing an arrayref to TIEHASH fails";
80 tie my @array, 'DBM::Deep', [ file => 't/test.db' ];
81 } qr/Not a hashref/, "Passing an arrayref to TIEARRAY fails";
85 tie my %hash, 'DBM::Deep', undef, file => 't/test.db';
86 } qr/Odd number of parameters/, "Odd number of params to TIEHASH fails";
90 tie my @array, 'DBM::Deep', undef, file => 't/test.db';
91 } qr/Odd number of parameters/, "Odd number of params to TIEARRAY fails";