use strict;
use Test::More tests => 49;
use Test::Exception;
-use t::common qw( new_fh );
+use t::common qw( new_dbm );
use_ok( 'DBM::Deep' );
-my ($fh, $filename) = new_fh();
-my $db = DBM::Deep->new( $filename );
+my $dbm_factory = new_dbm();
+while ( my $dbm_maker = $dbm_factory->() ) {
+my $db = $dbm_maker->();
##
# put/get key
# Make sure DB still works after closing / opening
##
undef $db;
-open $fh, '+<', $filename;
-$db = DBM::Deep->new( $filename );
+$db = $dbm_maker->();
is( $db->get("key1"), "value222222222222222222222222", "The value we set is still there after closure" );
##
$db->exists(undef);
} qr/Cannot use an undefined hash key/, "EXISTS fails on an undefined key";
+}
use base 'Exporter';
our @EXPORT_OK = qw(
+ new_dbm
new_fh
);
return ($fh, $filename);
}
+sub new_dbm {
+ my @args = @_;
+ my ($fh, $filename) = new_fh();
+ my @extra_args = (
+ [ file => $filename ],
+ );
+ return sub {
+ return unless @extra_args;
+ my @these_args = @{ shift @extra_args };
+ return sub {
+ DBM::Deep->new(
+ @these_args, @args,
+ );
+ };
+ };
+}
+
1;
__END__