X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F18_export.t;h=ddb2c14826679b3ce1e444a016bc636144576d5f;hb=0e3e35555b9d0f781548d4d383f601ba69837310;hp=949697a1d168ae81deb01840d3efdc4585b71358;hpb=4f0f6fff0474a896cad8bbb80d8c0ccce3d87bf9;p=dbsrgits%2FDBM-Deep.git diff --git a/t/18_export.t b/t/18_export.t index 949697a..ddb2c14 100644 --- a/t/18_export.t +++ b/t/18_export.t @@ -1,10 +1,9 @@ -## -# DBM::Deep Test -## use strict; -use Test::More tests => 6; +use warnings FATAL => 'all'; + +use Test::More; use Test::Deep; -use t::common qw( new_fh ); +use t::common qw( new_dbm ); use_ok( 'DBM::Deep' ); @@ -24,43 +23,44 @@ my %struct = ( }, ); -my ($fh, $filename) = new_fh(); -my $db = DBM::Deep->new({ - file => $filename, - autobless => 1, -}); +my $dbm_factory = new_dbm( autobless => 1 ); +while ( my $dbm_maker = $dbm_factory->() ) { + my $db = $dbm_maker->(); -## -# Create structure in DB -## -$db->import( \%struct ); + ## + # Create structure in DB + ## + $db->import( \%struct ); -## -# Export entire thing -## -my $compare = $db->export(); + ## + # Export entire thing + ## + my $compare = $db->export(); -cmp_deeply( - $compare, - { - key1 => "value1", - key2 => "value2", - array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ] ], - hash1 => { - subkey1 => "subvalue1", - subkey2 => "subvalue2", - subkey3 => bless( { - sub_obj => bless([ - bless([], 'Foo'), - ], 'Foo'), - sub_obj2 => bless([], 'Foo'), - }, 'Foo' ), + cmp_deeply( + $compare, + { + key1 => "value1", + key2 => "value2", + array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ] ], + hash1 => { + subkey1 => "subvalue1", + subkey2 => "subvalue2", + subkey3 => bless( { + sub_obj => bless([ + bless([], 'Foo'), + ], 'Foo'), + sub_obj2 => bless([], 'Foo'), + }, 'Foo' ), + }, }, - }, - "Everything matches", -); + "Everything matches", + ); + + isa_ok( tied(%{$db->{hash1}{subkey3}})->export, 'Foo' ); + isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj}})->export, 'Foo' ); + isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj}[0]})->export, 'Foo' ); + isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj2}})->export, 'Foo' ); +} -isa_ok( tied(%{$db->{hash1}{subkey3}})->export, 'Foo' ); -isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj}})->export, 'Foo' ); -isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj}[0]})->export, 'Foo' ); -isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj2}})->export, 'Foo' ); +done_testing;