From: rkinyon Date: Thu, 2 Mar 2006 15:47:13 +0000 (+0000) Subject: Failing test of using keys when referring to the head X-Git-Tag: 0-99_01~90 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1df992b378521651a666a5e274a19eeab78918ab;p=dbsrgits%2FDBM-Deep.git Failing test of using keys when referring to the head --- diff --git a/t/16_circular.t b/t/16_circular.t index 0456a38..51ff250 100644 --- a/t/16_circular.t +++ b/t/16_circular.t @@ -2,7 +2,7 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 13; +use Test::More tests => 19; use File::Temp qw( tempfile tempdir ); use_ok( 'DBM::Deep' ); @@ -17,11 +17,45 @@ my $db = DBM::Deep->new( $filename ); $db->{key1} = "value1"; $db->{key2} = "value2"; +my @keys_1 = sort keys %$db; + +$db->{key3} = $db->{key1}; + +my @keys_2 = sort keys %$db; +is( @keys_2 + 0, @keys_1 + 1, "Correct number of keys" ); +is_deeply( + [ @keys_1, 'key3' ], + [ @keys_2 ], + "Keys still match after circular reference is added", +); + +$db->{key4} = {}; +$db->{key4}{key1} = 'value1'; +$db->{key4}{key2} = $db->{key4}; + +my @keys_3 = sort keys %$db; +is( @keys_3 + 0, @keys_2 + 1, "Correct number of keys" ); +is_deeply( + [ @keys_2, 'key4' ], + [ @keys_3 ], + "Keys still match after circular reference is added", +); + ## # Insert circular reference ## $db->{circle} = $db; +my @keys_4 = sort keys %$db; +print "@keys_4\n"; + +is( @keys_4 + 0, @keys_3 + 1, "Correct number of keys" ); +is_deeply( + [ '[base]', @keys_3 ], + [ @keys_4 ], + "Keys still match after circular reference is added", +); + ## # Make sure keys exist in both places ##