From: rkinyon Date: Sat, 25 Mar 2006 02:08:43 +0000 (+0000) Subject: Added autovivification tests X-Git-Tag: 0-99_01~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b603f25bb538f5b30a45946d36a6ffc3c12eaa5;p=dbsrgits%2FDBM-Deep.git Added autovivification tests --- diff --git a/t/02_hash.t b/t/02_hash.t index 5f772fb..b1a41fd 100644 --- a/t/02_hash.t +++ b/t/02_hash.t @@ -2,7 +2,7 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 30; +use Test::More tests => 32; use Test::Exception; use File::Temp qw( tempfile tempdir ); use Fcntl qw( :flock ); @@ -119,3 +119,9 @@ ok( ($first_key ne $next_key) ,"keys() still works if you replace long values with shorter ones" ); + +# Test autovivification + +$db->{unknown}{bar} = 1; +ok( $db->{unknown} ); +cmp_ok( $db->{unknown}{bar}, '==', 1 ); diff --git a/t/04_array.t b/t/04_array.t index d5e5138..f3a6860 100644 --- a/t/04_array.t +++ b/t/04_array.t @@ -2,7 +2,7 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 107; +use Test::More tests => 109; use Test::Exception; use File::Temp qw( tempfile tempdir ); use Fcntl qw( :flock ); @@ -208,3 +208,9 @@ $db->[0] = [ 1 .. 3 ]; $db->[1] = { a => 'foo' }; is( $db->[1]->fetch('a'), 'foo', "Reuse of same space with hash successful" ); is( $db->[0]->length, 3, "Reuse of same space with array successful" ); + +# Test autovivification + +$db->[9999]{bar} = 1; +ok( $db->[9999] ); +cmp_ok( $db->[9999]{bar}, '==', 1 );