X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F22_internal_copy.t;h=0988f8da5d39c12108899daa953c32b7f503e88c;hb=5c0756fcb3b5c7ca76c52be6c7c9d78841e5d57b;hp=9de69f42ca0cd4bf3e9ba011a942dc14b83b878b;hpb=1cff45d771d12ad40ac87c46082711f5becd6a4c;p=dbsrgits%2FDBM-Deep.git diff --git a/t/22_internal_copy.t b/t/22_internal_copy.t index 9de69f4..0988f8d 100644 --- a/t/22_internal_copy.t +++ b/t/22_internal_copy.t @@ -8,20 +8,20 @@ use t::common qw( new_fh ); use_ok( 'DBM::Deep' ); my ($fh, $filename) = new_fh(); -my $db = DBM::Deep->new( $filename ); +my $db = DBM::Deep->new( file => $filename, fh => $fh, ); ## # Create structure in $db ## -$db->import( - hash1 => { - subkey1 => "subvalue1", - subkey2 => "subvalue2", - }, +$db->import({ + hash1 => { + subkey1 => "subvalue1", + subkey2 => "subvalue2", + }, hash2 => { subkey3 => 'subvalue3', }, -); +}); is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" ); is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" ); @@ -49,16 +49,19 @@ my $max_keys = 1000; my ($fh2, $filename2) = new_fh(); { - my $db = DBM::Deep->new( $filename2 ); + my $db = DBM::Deep->new( file => $filename2, fh => $fh2, ); $db->{foo} = [ 1 .. 3 ]; for ( 0 .. $max_keys ) { $db->{'foo' . $_} = $db->{foo}; } + ## Rewind handle otherwise the signature is not recognised below. + ## The signature check should probably rewind the fh? + seek $db->_get_self->_storage->{fh}, 0, 0; } { - my $db = DBM::Deep->new( $filename2 ); + my $db = DBM::Deep->new( fh => $fh2, ); my $base_offset = $db->{foo}->_base_offset; my $count = -1;