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, |
45f047f8 |
24 | fh => $fh, |
2a81bf9e |
25 | type => DBM::Deep->TYPE_ARRAY, |
26 | ); |
ffed8b01 |
27 | |
2a81bf9e |
28 | $db->[0] = []; |
29 | my $temp_db = $db->[0]; |
30 | for my $k ( 0 .. $max_levels ) { |
31 | $temp_db->[$k] = []; |
32 | $temp_db = $temp_db->[$k]; |
33 | } |
34 | $temp_db->[0] = "deepvalue"; |
ffed8b01 |
35 | } |
ffed8b01 |
36 | |
2a81bf9e |
37 | { |
45f047f8 |
38 | open $fh, '+<', $filename; |
2a81bf9e |
39 | my $db = DBM::Deep->new( |
40 | file => $filename, |
45f047f8 |
41 | fh => $fh, |
2a81bf9e |
42 | type => DBM::Deep->TYPE_ARRAY, |
43 | ); |
ffed8b01 |
44 | |
2a81bf9e |
45 | my $cur_level = -1; |
46 | my $temp_db = $db->[0]; |
47 | for my $k ( 0 .. $max_levels ) { |
48 | $cur_level = $k; |
49 | $temp_db = $temp_db->[$k]; |
50 | eval { $temp_db->isa( 'DBM::Deep' ) } or last; |
51 | } |
52 | is( $cur_level, $max_levels, "We read all the way down to level $cur_level" ); |
53 | is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" ); |
ffed8b01 |
54 | } |