r11685@rob-kinyons-powerbook58: rob | 2006-04-29 10:50:27 -0400
[dbsrgits/DBM-Deep.git] / t / 09_deeparray.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 3;
6 use t::common qw( new_fh );
7
8 diag "This test can take up to a minute to run. Please be patient.";
9
10 use_ok( 'DBM::Deep' );
11
12 my ($fh, $filename) = new_fh();
13
14 my $max_levels = 1000;
15
16 {
17     my $db = DBM::Deep->new(
18         file => $filename,
19         type => DBM::Deep->TYPE_ARRAY,
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 }
30
31 {
32     my $db = DBM::Deep->new(
33         file => $filename,
34         type => DBM::Deep->TYPE_ARRAY,
35     );
36
37     my $cur_level = -1;
38     my $temp_db = $db->[0];
39     for my $k ( 0 .. $max_levels ) {
40         $cur_level = $k;
41         $temp_db = $temp_db->[$k];
42         eval { $temp_db->isa( 'DBM::Deep' ) } or last;
43     }
44     is( $cur_level, $max_levels, "We read all the way down to level $cur_level" );
45     is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" );
46 }