From: rkinyon Date: Mon, 6 Mar 2006 14:42:31 +0000 (+0000) Subject: Added fix for RT#17947 and fixed a bug from last checkin X-Git-Tag: 0-99_01~75 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c9cec40e1c65cb1a386d84f0dd23b0cc6ce64f5f;p=dbsrgits%2FDBM-Deep.git Added fix for RT#17947 and fixed a bug from last checkin --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index 8e27817..280585c 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -278,19 +278,13 @@ sub import { ## # Recursively import Perl hash/array structure ## - #XXX This use of ref() seems to be ok if (!ref($_[0])) { return; } # Perl calls import() on use -- ignore my $self = shift->_get_self; my ($struct) = @_; - #XXX This use of ref() seems to be ok + # struct is not a reference, so just import based on our type if (!ref($struct)) { - ## - # struct is not a reference, so just import based on our type - ## - shift @_; - if ($self->_type eq TYPE_HASH) { $struct = {@_}; } elsif ($self->_type eq TYPE_ARRAY) { $struct = [@_]; } } diff --git a/t/04_array.t b/t/04_array.t index 7529056..7a146ef 100644 --- a/t/04_array.t +++ b/t/04_array.t @@ -54,7 +54,10 @@ is( $db->[-2], $db->[3], "-2nd index is 3rd index" ); is( $db->[-3], $db->[2], "-3rd index is 2nd index" ); is( $db->[-4], $db->[1], "-4th index is 1st index" ); is( $db->[-5], $db->[0], "-5th index is 0th index" ); -is( $db->[-6], undef, "-6th index is undef" ); + +# This is for Perls older than 5.8.0 because of is()'s prototype +{ my $v = $db->[-6]; is( $v, undef, "-6th index is undef" ); } + is( $db->length, 5, "... and we have five elements after abortive -6 index lookup" ); $db->[-1] = 'elem4.1'; diff --git a/t/19_crossref.t b/t/19_crossref.t index e01810c..8ce2cc0 100644 --- a/t/19_crossref.t +++ b/t/19_crossref.t @@ -21,10 +21,9 @@ my $db2 = DBM::Deep->new( $filename2 ); $db->import( hash1 => { subkey1 => "subvalue1", - subkey2 => "subvalue2" + subkey2 => "subvalue2", } ); - is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" ); is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );