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