Removed last holdouts of t/test?.db
[dbsrgits/DBM-Deep.git] / t / 19_crossref.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 5;
98ac82af 6use File::Temp qw( tempfile tempdir );
ffed8b01 7
8use_ok( 'DBM::Deep' );
9
98ac82af 10my $dir = tempdir( CLEANUP => 1 );
11my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
12my $db2 = DBM::Deep->new( $filename2 );
13
14{
15 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
16 my $db = DBM::Deep->new( $filename );
17
18 ##
19 # Create structure in $db
20 ##
21 $db->import(
22 hash1 => {
23 subkey1 => "subvalue1",
24 subkey2 => "subvalue2"
25 }
26 );
27
28 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
29 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
30
31 ##
32 # Cross-ref nested hash accross DB objects
33 ##
34 $db2->{copy} = $db->{hash1};
35}
ffed8b01 36
37##
38# Make sure $db2 has copy of $db's hash structure
39##
40is( $db2->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
41is( $db2->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );