Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
535203b1 |
5 | use Test::More; |
6 | |
7 | plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests" |
8 | unless $ENV{LONG_TESTS}; |
9 | |
10 | plan tests => 3; |
fde3db1a |
11 | use t::common qw( new_fh ); |
ffed8b01 |
12 | |
13ff93d5 |
13 | diag "This test can take up to a minute to run. Please be patient."; |
14 | |
2a81bf9e |
15 | use_ok( 'DBM::Deep' ); |
ffed8b01 |
16 | |
fde3db1a |
17 | my ($fh, $filename) = new_fh(); |
ffed8b01 |
18 | |
2a81bf9e |
19 | my $max_levels = 1000; |
ffed8b01 |
20 | |
2a81bf9e |
21 | { |
22 | my $db = DBM::Deep->new( |
23 | file => $filename, |
24 | type => DBM::Deep->TYPE_ARRAY, |
25 | ); |
ffed8b01 |
26 | |
2a81bf9e |
27 | $db->[0] = []; |
28 | my $temp_db = $db->[0]; |
29 | for my $k ( 0 .. $max_levels ) { |
30 | $temp_db->[$k] = []; |
31 | $temp_db = $temp_db->[$k]; |
32 | } |
33 | $temp_db->[0] = "deepvalue"; |
ffed8b01 |
34 | } |
ffed8b01 |
35 | |
2a81bf9e |
36 | { |
37 | my $db = DBM::Deep->new( |
38 | file => $filename, |
39 | type => DBM::Deep->TYPE_ARRAY, |
40 | ); |
ffed8b01 |
41 | |
2a81bf9e |
42 | my $cur_level = -1; |
43 | my $temp_db = $db->[0]; |
44 | for my $k ( 0 .. $max_levels ) { |
45 | $cur_level = $k; |
46 | $temp_db = $temp_db->[$k]; |
47 | eval { $temp_db->isa( 'DBM::Deep' ) } or last; |
48 | } |
49 | is( $cur_level, $max_levels, "We read all the way down to level $cur_level" ); |
50 | is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" ); |
ffed8b01 |
51 | } |