$self->_engine->storage->{filter_fetch_value} = undef;
# If there is no flushing, then things get out of sync.
-# warn "FETCHSIZE BEG: " . $self->_engine->_dump_file;
my $size = $self->FETCH('length') || 0;
-# warn "FETCHSIZE AFT: " . $self->_engine->_dump_file;
$self->_engine->storage->{filter_fetch_value} = $SAVE_FILTER;
$self->unlock;
-# warn "FETCHSIZE END: " . $self->_engine->_dump_file;
-
return $size;
}
$self->_move_value( $i, $i+$new_size );
}
-# warn "BEFORE: " . $self->_dump_file;
$self->STORESIZE( $length + $new_size );
}
-# $self->_engine->flush;
for (my $i = 0; $i < $new_size; $i++) {
$self->STORE( $i, $new_elements[$i] );
}
- warn "AFTER : " . $self->_dump_file;
$self->unlock;
}
# Need to load the new sector so we can read from it.
- my $new_sector = $self->engine->storage->read_at( $loc, $size );
+ my $new_sector = $self->engine->get_data( $loc, $size );
# Read the new head after the signature and the staleness counter
- my $new_head = substr( $new_sector, $e->SIG_SIZE + $DBM::Deep::Engine::STALE_SIZE, $e->byte_size );
+ my $new_head = substr( $$new_sector, $e->SIG_SIZE + $DBM::Deep::Engine::STALE_SIZE, $e->byte_size );
$self->write( $e->chains_loc + $chains_offset, $new_head );
$db->push( "elem2" );
$db->put(2, "elem3");
$db->store(3, "elem4");
-#warn $db->_engine->_dump_file;
$db->unshift("elem0");
-#warn $db->_engine->_dump_file;
-#__END__
is( $db->[0], 'elem0', "Array get for shift works" );
is( $db->[1], 'elem1', "Array get for array set works" );
throws_ok {
$db->[-6] = 'whoops!';
-} qr/Modification of non-creatable array value attempted, subscript -6/, "Correct error thrown";
+} qr/Modification of non-creatable array value attempted, subscript -6/,
+ "Correct error thrown when attempting to modify a non-creatable array value";
-warn "1: \n" . $db->_engine->_dump_file;
my $popped = $db->pop;
-warn "2: \n" . $db->_engine->_dump_file;
is( $db->length, 4, "... and we have four after popping" );
-warn "3: \n" . $db->_engine->_dump_file;
is( $db->[0], 'elem0', "0th element still there after popping" );
-warn "4: \n" . $db->_engine->_dump_file;
is( $db->[1], 'elem1', "1st element still there after popping" );
-warn "5: \n" . $db->_engine->_dump_file;
is( $db->[2], 'elem2', "2nd element still there after popping" );
-warn "6: \n" . $db->_engine->_dump_file;
is( $db->[3], 'elem3', "3rd element still there after popping" );
-warn "7: \n" . $db->_engine->_dump_file;
is( $popped, 'elem4.1', "Popped value is correct" );
-die $db->_engine->_dump_file;
-
my $shifted = $db->shift;
is( $db->length, 3, "... and we have three after shifting" );
is( $db->[0], 'elem1', "0th element still there after shifting" );
is( $db->shift, undef, "shift on an empty array returns undef" );
is( $db->length(), 0, "After shift() on empty array, length is still 0" );
-warn "BEFORE: " . $db->_engine->_dump_file;
-__END__
is( $db->unshift( 1, 2, 3 ), 3, "unshift returns the number of elements in the array" );
is( $db->unshift( 1, 2, 3 ), 6, "unshift returns the number of elements in the array" );
is( $db->push( 1, 2, 3 ), 9, "push returns the number of elements in the array" );