Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
995d119b |
4 | $|++; |
ffed8b01 |
5 | use strict; |
6 | use Test::More; |
7 | |
8 | my $max_levels = 1000; |
9 | |
995d119b |
10 | plan tests => 3; |
ffed8b01 |
11 | |
12 | use_ok( 'DBM::Deep' ); |
13 | |
14 | unlink "t/test.db"; |
15 | my $db = DBM::Deep->new( |
16 | file => "t/test.db", |
17 | type => DBM::Deep->TYPE_ARRAY, |
18 | ); |
19 | if ($db->error()) { |
20 | die "ERROR: " . $db->error(); |
21 | } |
22 | |
23 | $db->[0] = []; |
24 | my $temp_db = $db->[0]; |
25 | for my $k ( 0 .. $max_levels ) { |
26 | $temp_db->[$k] = []; |
27 | $temp_db = $temp_db->[$k]; |
28 | } |
29 | $temp_db->[0] = "deepvalue"; |
30 | undef $temp_db; |
31 | |
32 | undef $db; |
33 | $db = DBM::Deep->new( |
34 | file => "t/test.db", |
35 | type => DBM::Deep->TYPE_ARRAY, |
36 | ); |
37 | |
995d119b |
38 | my $cur_level = -1; |
ffed8b01 |
39 | $temp_db = $db->[0]; |
40 | for my $k ( 0 .. $max_levels ) { |
995d119b |
41 | $cur_level = $k; |
ffed8b01 |
42 | $temp_db = $temp_db->[$k]; |
995d119b |
43 | eval { $temp_db->isa( 'DBM::Deep' ) } or last; |
ffed8b01 |
44 | } |
995d119b |
45 | is( $cur_level, $max_levels, "We read all the way down to level $cur_level" ); |
ffed8b01 |
46 | is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" ); |