$self->lock( $self->LOCK_SH );
- if ( $key =~ /^-?\d+$/ ) {
+ if ( !defined $key ) {
+ DBM::Deep->_throw_error( "Cannot use an undefined array index." );
+ }
+ elsif ( $key =~ /^-?\d+$/ ) {
if ( $key < 0 ) {
$key += $self->FETCHSIZE;
unless ( $key >= 0 ) {
my $size;
my $idx_is_numeric;
- if ( $key =~ /^\-?\d+$/ ) {
+ if ( !defined $key ) {
+ DBM::Deep->_throw_error( "Cannot use an undefined array index." );
+ }
+ elsif ( $key =~ /^-?\d+$/ ) {
$idx_is_numeric = 1;
if ( $key < 0 ) {
$size = $self->FETCHSIZE;
$self->lock( $self->LOCK_SH );
- if ( $key =~ /^\-?\d+$/ ) {
+ if ( !defined $key ) {
+ DBM::Deep->_throw_error( "Cannot use an undefined array index." );
+ }
+ elsif ( $key =~ /^-?\d+$/ ) {
if ( $key < 0 ) {
$key += $self->FETCHSIZE;
unless ( $key >= 0 ) {
$self->lock( $self->LOCK_EX );
my $size = $self->FETCHSIZE;
- if ( $key =~ /^-?\d+$/ ) {
+ if ( !defined $key ) {
+ DBM::Deep->_throw_error( "Cannot use an undefined array index." );
+ }
+ elsif ( $key =~ /^-?\d+$/ ) {
if ( $key < 0 ) {
$key += $size;
unless ( $key >= 0 ) {
# DBM::Deep Test
##
use strict;
-use Test::More tests => 112;
+use Test::More tests => 116;
use Test::Exception;
use t::common qw( new_fh );
} qr/Cannot use 'foo' as an array index/, "FETCH fails on an illegal key";
throws_ok {
+ $db->fetch();
+} qr/Cannot use an undefined array index/, "FETCH fails on an undefined key";
+
+throws_ok {
$db->store( 'foo', 'bar' );
} qr/Cannot use 'foo' as an array index/, "STORE fails on an illegal key";
throws_ok {
+ $db->store();
+} qr/Cannot use an undefined array index/, "FETCH fails on an undefined key";
+
+throws_ok {
$db->delete( 'foo' );
} qr/Cannot use 'foo' as an array index/, "STORE fails on an illegal key";
throws_ok {
+ $db->delete();
+} qr/Cannot use an undefined array index/, "FETCH fails on an undefined key";
+
+throws_ok {
$db->exists( 'foo' );
} qr/Cannot use 'foo' as an array index/, "STORE fails on an illegal key";
+
+throws_ok {
+ $db->exists();
+} qr/Cannot use an undefined array index/, "FETCH fails on an undefined key";
+