The header now has its own sector. A lot needs to be moved over to it, but it's there.
[dbsrgits/DBM-Deep.git] / t / 04_array.t
index 01eb346..3bfc933 100644 (file)
@@ -2,7 +2,7 @@
 # DBM::Deep Test
 ##
 use strict;
-use Test::More tests => 125;
+use Test::More tests => 128;
 use Test::Exception;
 use t::common qw( new_fh );
 
@@ -10,18 +10,22 @@ use_ok( 'DBM::Deep' );
 
 my ($fh, $filename) = new_fh();
 my $db = DBM::Deep->new(
-       file => $filename,
-       type => DBM::Deep->TYPE_ARRAY
+    file => $filename,
+    fh => $fh,
+    type => DBM::Deep->TYPE_ARRAY
 );
 
 ##
 # basic put/get/push
 ##
 $db->[0] = "elem1";
-$db->push( "elem2" );
-$db->put(2, "elem3");
-$db->store(3, "elem4");
+#$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" );
@@ -62,7 +66,7 @@ is( $db->fetch(4), 'elem4.1' );
 
 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";
 
 my $popped = $db->pop;
 is( $db->length, 4, "... and we have four after popping" );
@@ -197,6 +201,11 @@ is($db->[0], "elem first");
 is($db->[1], "elem last");
 is($returned[0], "middle ABC");
 
+@returned = $db->splice;
+is( $db->length, 0 );
+is( $returned[0], "elem first" );
+is( $returned[1], "elem last" );
+
 $db->[0] = [ 1 .. 3 ];
 $db->[1] = { a => 'foo' };
 is( $db->[0]->length, 3, "Reuse of same space with array successful" );
@@ -246,6 +255,7 @@ throws_ok {
     my ($fh, $filename) = new_fh();
     my $db = DBM::Deep->new(
         file => $filename,
+        fh => $fh,
         type => DBM::Deep->TYPE_ARRAY
     );