Commit | Line | Data |
ffed8b01 |
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 | if ($db->error()) { |
12 | die "ERROR: " . $db->error(); |
13 | } |
14 | |
15 | ## |
16 | # put/get simple keys |
17 | ## |
18 | $db->{key1} = "value1"; |
19 | $db->{key2} = "value2"; |
20 | |
21 | ## |
22 | # Insert circular reference |
23 | ## |
24 | $db->{circle} = $db; |
25 | |
26 | ## |
27 | # Make sure keys exist in both places |
28 | ## |
29 | is( $db->{key1}, 'value1', "The value is there directly" ); |
30 | is( $db->{circle}{key1}, 'value1', "The value is there in one loop of the circle" ); |
31 | is( $db->{circle}{circle}{key1}, 'value1', "The value is there in two loops of the circle" ); |
32 | is( $db->{circle}{circle}{circle}{key1}, 'value1', "The value is there in three loops of the circle" ); |
33 | |
34 | ## |
35 | # Make sure changes are reflected in both places |
36 | ## |
37 | $db->{key1} = "another value"; |
38 | |
39 | is( $db->{key1}, 'another value', "The value is there directly" ); |
40 | is( $db->{circle}{key1}, 'another value', "The value is there in one loop of the circle" ); |
41 | is( $db->{circle}{circle}{key1}, 'another value', "The value is there in two loops of the circle" ); |
42 | is( $db->{circle}{circle}{circle}{key1}, 'another value', "The value is there in three loops of the circle" ); |
43 | |
44 | $db->{circle}{circle}{circle}{circle}{key1} = "circles"; |
45 | |
46 | is( $db->{key1}, 'circles', "The value is there directly" ); |
47 | is( $db->{circle}{key1}, 'circles', "The value is there in one loop of the circle" ); |
48 | is( $db->{circle}{circle}{key1}, 'circles', "The value is there in two loops of the circle" ); |
49 | is( $db->{circle}{circle}{circle}{key1}, 'circles', "The value is there in three loops of the circle" ); |