Removed error/clear_error functions
[dbsrgits/DBM-Deep.git] / t / 16_circular.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 13;
6
7 use_ok( 'DBM::Deep' );
8
9 unlink "t/test.db";
10 my $db = DBM::Deep->new( "t/test.db" );
11
12 ##
13 # put/get simple keys
14 ##
15 $db->{key1} = "value1";
16 $db->{key2} = "value2";
17
18 ##
19 # Insert circular reference
20 ##
21 $db->{circle} = $db;
22
23 ##
24 # Make sure keys exist in both places
25 ##
26 is( $db->{key1}, 'value1', "The value is there directly" );
27 is( $db->{circle}{key1}, 'value1', "The value is there in one loop of the circle" );
28 is( $db->{circle}{circle}{key1}, 'value1', "The value is there in two loops of the circle" );
29 is( $db->{circle}{circle}{circle}{key1}, 'value1', "The value is there in three loops of the circle" );
30
31 ##
32 # Make sure changes are reflected in both places
33 ##
34 $db->{key1} = "another value";
35
36 is( $db->{key1}, 'another value', "The value is there directly" );
37 is( $db->{circle}{key1}, 'another value', "The value is there in one loop of the circle" );
38 is( $db->{circle}{circle}{key1}, 'another value', "The value is there in two loops of the circle" );
39 is( $db->{circle}{circle}{circle}{key1}, 'another value', "The value is there in three loops of the circle" );
40
41 $db->{circle}{circle}{circle}{circle}{key1} = "circles";
42
43 is( $db->{key1}, 'circles', "The value is there directly" );
44 is( $db->{circle}{key1}, 'circles', "The value is there in one loop of the circle" );
45 is( $db->{circle}{circle}{key1}, 'circles', "The value is there in two loops of the circle" );
46 is( $db->{circle}{circle}{circle}{key1}, 'circles', "The value is there in three loops of the circle" );