5 use Test::More tests => 13;
6 use File::Temp qw( tempfile tempdir );
10 my $dir = tempdir( CLEANUP => 1 );
11 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
12 my $db = DBM::Deep->new( $filename );
17 $db->{key1} = "value1";
18 $db->{key2} = "value2";
21 # Insert circular reference
26 # Make sure keys exist in both places
28 is( $db->{key1}, 'value1', "The value is there directly" );
29 is( $db->{circle}{key1}, 'value1', "The value is there in one loop of the circle" );
30 is( $db->{circle}{circle}{key1}, 'value1', "The value is there in two loops of the circle" );
31 is( $db->{circle}{circle}{circle}{key1}, 'value1', "The value is there in three loops of the circle" );
34 # Make sure changes are reflected in both places
36 $db->{key1} = "another value";
38 is( $db->{key1}, 'another value', "The value is there directly" );
39 is( $db->{circle}{key1}, 'another value', "The value is there in one loop of the circle" );
40 is( $db->{circle}{circle}{key1}, 'another value', "The value is there in two loops of the circle" );
41 is( $db->{circle}{circle}{circle}{key1}, 'another value', "The value is there in three loops of the circle" );
43 $db->{circle}{circle}{circle}{circle}{key1} = "circles";
45 is( $db->{key1}, 'circles', "The value is there directly" );
46 is( $db->{circle}{key1}, 'circles', "The value is there in one loop of the circle" );
47 is( $db->{circle}{circle}{key1}, 'circles', "The value is there in two loops of the circle" );
48 is( $db->{circle}{circle}{circle}{key1}, 'circles', "The value is there in three loops of the circle" );