5 use Test::More tests => 6;
7 use File::Temp qw( tempfile tempdir );
8 use Fcntl qw( :flock );
10 use_ok( 'DBM::Deep' );
12 my $dir = tempdir( CLEANUP => 1 );
13 my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
15 my $db2 = DBM::Deep->new( $filename2 );
18 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
20 my $db = DBM::Deep->new( $filename );
23 # Create structure in $db
27 subkey1 => "subvalue1",
28 subkey2 => "subvalue2",
31 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
32 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
35 # Cross-ref nested hash accross DB objects
38 $db2->{copy} = $db->{hash1};
39 } qr/Cannot cross-reference\. Use export\(\) instead/, "cross-ref fails";
40 $db2->{copy} = $db->{hash1}->export;
44 # Make sure $db2 has copy of $db's hash structure
46 is( $db2->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
47 is( $db2->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );