From: jhuckaby Date: Thu, 23 Feb 2006 08:19:15 +0000 (+0000) Subject: Added test for special case where hash is stored blessed into class with short name... X-Git-Tag: 0-97~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70d0fb51f35621bc9ec320230d1950f64318ce15;p=dbsrgits%2FDBM-Deep.git Added test for special case where hash is stored blessed into class with short name, then is replaced with hash blessed into class with longer name. --- diff --git a/t/24_autobless.t b/t/24_autobless.t index 069afd0..b40cbd7 100644 --- a/t/24_autobless.t +++ b/t/24_autobless.t @@ -7,7 +7,7 @@ use strict; sub foo { 'foo' }; } -use Test::More tests => 28; +use Test::More tests => 29; use_ok( 'DBM::Deep' ); @@ -133,3 +133,31 @@ undef $db3; isa_ok( $blessed, 'Foo' ); is( $blessed->{a}, 1 ); } + +{ + ## + # test blessing hash into short named class (Foo), then re-blessing into + # longer named class (FooFoo) and replacing key in db file, then validating + # content after that point in file to check for corruption. + ## + unlink 't/test.db'; + my $db = DBM::Deep->new( + file => "t/test.db", + autobless => 1, + ); + if ($db->error()) { + die "ERROR: " . $db->error(); + } + + my $obj = bless {}, 'Foo'; + + $db->{blessed} = $obj; + $db->{after} = "hello"; + + my $obj2 = bless {}, 'FooFoo'; + + $db->{blessed} = $obj2; + + is( $db->{after}, "hello" ); +} +