From: rkinyon Date: Sat, 18 Mar 2006 14:37:34 +0000 (+0000) Subject: More tests X-Git-Tag: 0-99_01~54 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6ea6b6cea2f279a53f6633007c8156ec6b513d7;p=dbsrgits%2FDBM-Deep.git More tests --- diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index 36480c9..d300451 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -595,7 +595,8 @@ sub read_from_loc { seek($fh, $self->{data_size} + $self->{index_size}, SEEK_CUR); my $size; - read( $fh, $size, $self->{data_size}); $size = unpack($self->{data_pack}, $size); + read( $fh, $size, $self->{data_size}); + $size = unpack($self->{data_pack}, $size); if ($size) { seek($fh, $size, SEEK_CUR); } my $bless_bit; @@ -605,7 +606,8 @@ sub read_from_loc { # Yes, object needs to be re-blessed ## my $class_name; - read( $fh, $size, $self->{data_size}); $size = unpack($self->{data_pack}, $size); + read( $fh, $size, $self->{data_size}); + $size = unpack($self->{data_pack}, $size); if ($size) { read( $fh, $class_name, $size); } if ($class_name) { $new_obj = bless( $new_obj, $class_name ); } } diff --git a/t/31_references.t b/t/31_references.t index 9833faf..af5fc32 100644 --- a/t/31_references.t +++ b/t/31_references.t @@ -2,7 +2,7 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 6; +use Test::More tests => 15; use Test::Exception; use File::Temp qw( tempfile tempdir ); use Fcntl qw( :flock ); @@ -29,3 +29,29 @@ is_deeply( $db->{hash}{baz}, { a => 42 } ); $hash{foo} = 2; is( $db->{hash}{foo}, 2 ); + +$hash{bar}[1] = 90; +is( $db->{hash}{bar}[1], 90 ); + +$hash{baz}{b} = 33; +is( $db->{hash}{baz}{b}, 33 ); + +my @array = ( + 1, [ 1 .. 3 ], { a => 42 }, +); + +$db->{array} = \@array; +isa_ok( tied(@array), 'DBM::Deep::Array' ); + +is( $db->{array}[0], 1 ); +is_deeply( $db->{array}[1], [ 1 .. 3 ] ); +is_deeply( $db->{array}[2], { a => 42 } ); + +$array[0] = 2; +is( $db->{array}[0], 2 ); + +$array[1][2] = 9; +is( $db->{array}[1][2], 9 ); + +$array[2]{b} = 'floober'; +is( $db->{array}[2]{b}, 'floober' );