5 use Test::More tests => 7;
7 use t::common qw( new_fh );
11 my ($fh, $filename) = new_fh();
15 tie %hash, 'DBM::Deep', $filename;
17 $hash{key1} = 'value';
18 is( $hash{key1}, 'value', 'Set and retrieved key1' );
19 tied( %hash )->_get_self->_storage->close( tied( %hash )->_get_self );
24 tie %hash, 'DBM::Deep', $filename;
26 is( $hash{key1}, 'value', 'Set and retrieved key1' );
28 is( keys %hash, 1, "There's one key so far" );
29 ok( exists $hash{key1}, "... and it's key1" );
30 tied( %hash )->_get_self->_storage->close( tied( %hash )->_get_self );
35 tie my @array, 'DBM::Deep', {
37 type => DBM::Deep->TYPE_ARRAY,
39 tied( @array )->_get_self->_storage->close( tied( @array )->_get_self );
40 } qr/DBM::Deep: File type mismatch/, "\$SIG_TYPE doesn't match file's type";
44 my ($fh, $filename) = new_fh();
45 my $db = DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY );
48 tie my %hash, 'DBM::Deep', {
50 type => DBM::Deep->TYPE_HASH,
52 } qr/DBM::Deep: File type mismatch/, "\$SIG_TYPE doesn't match file's type";
53 $db->_get_self->_storage->close( $db->_get_self );