5 use Test::More tests => 15;
10 my $db = DBM::Deep->new( "t/test.db" );
12 die "ERROR: " . $db->error();
16 my $db2 = DBM::Deep->new( "t/test2.db" );
18 die "ERROR: " . $db2->error();
22 # Create structure in $db
26 subkey1 => "subvalue1",
27 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
37 $db2->{copy} = $db->{hash1};
39 $db->{hash1}{subkey3} = 'where does this go?';
40 is( $db->{hash1}{subkey3}, 'where does this go?' );
42 $db2->{copy}{subkey4} = 'from the other side';
43 is( $db2->{copy}{subkey4}, 'from the other side' );
46 # This is the failure case
49 my $left = $db->{hash1};
50 $db2->{right} = $left;
52 $db2->{right}{rightward} = 'floober';
53 is( $db2->{right}{rightward}, 'floober' );
54 isnt( $db->{hash1}{rightward}, 'floober' );
66 my $db3 = DBM::Deep->new( 't/test.db' );
68 die "ERROR: " . $db3->error();
70 is( $db3->{hash1}{subkey1}, 'subvalue1' );
71 is( $db3->{hash1}{subkey2}, 'subvalue2' );
72 is( $db3->{hash1}{subkey3}, 'where does this go?' );
73 isnt( $db3->{hash1}{subkey4}, 'from the other side' );
79 # Make sure $db2 has copy of $db's hash structure
81 is( $db2->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
82 is( $db2->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );
83 isnt( $db2->{copy}{subkey3}, 'where does this go?' );
84 is( $db2->{copy}{subkey4}, 'from the other side' );