if (!$bytes_read) {
seek($fh, 0, SEEK_SET);
print($fh SIG_FILE);
- $self->root->{end} = length(SIG_FILE);
$self->_create_tag($self->base_offset, $self->type, chr(0) x $INDEX_SIZE);
my $plain_key = "[base]";
print($fh pack($DATA_LENGTH_PACK, length($plain_key)) . $plain_key );
- $self->root->{end} += $DATA_LENGTH_SIZE + length($plain_key);
# Flush the filehandle
my $old_fh = select $fh;
$| = $old_af;
select $old_fh;
+ my @stats = stat($fh);
+ $self->root->{inode} = $stats[1];
+ $self->root->{end} = $stats[7];
+
return 1;
}
# DBM::Deep Test
##
use strict;
-use Test;
-BEGIN { plan tests => 2 }
+use Test::More tests => 3;
-use DBM::Deep;
+use_ok( 'DBM::Deep' );
##
# basic file open
##
unlink "t/test.db";
-my $db = new DBM::Deep(
+my $db = DBM::Deep->new(
file => "t/test.db",
locking => 1
);
# basic put/get
##
$db->{key1} = "value1";
-ok( $db->{key1} eq "value1" );
+is( $db->{key1}, "value1", "key1 is set" );
##
# explicit lock
##
-$db->lock( DBM::Deep::LOCK_EX );
+$db->lock( DBM::Deep->LOCK_EX );
$db->{key1} = "value2";
$db->unlock();
-ok( $db->{key1} eq "value2" );
-
-##
-# close, delete file, exit
-##
-undef $db;
-unlink "t/test.db";
-exit(0);
+is( $db->{key1}, "value2", "key1 is overridden" );