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" );
73 # These are testing the naive use of ref() within TIEHASH and TIEARRAY.
74 # They should be doing (Scalar::Util::reftype($_[0]) eq 'HASH') and then
75 # erroring out if it's not.
77 todo_skip( "Naive use of {\@_}", 1 );
80 my $db = tie %hash, 'DBM::Deep', [
85 print "ERROR: " . $db->error();
93 todo_skip( "Naive use of {\@_}", 1 );
96 my $db = tie @array, 'DBM::Deep', [
101 print "ERROR: " . $db->error();
110 tie my %hash, 'DBM::Deep', undef, file => 't/test.db';
111 } qr/Odd number of parameters/, "Odd number of params to TIEHASH fails";
115 tie my @array, 'DBM::Deep', undef, file => 't/test.db';
116 } qr/Odd number of parameters/, "Odd number of params to TIEARRAY fails";