Converted all relevant tests to use new_dbm instead of new_fh and all tests (except...
[dbsrgits/DBM-Deep.git] / t / 09_deeparray.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More;
5
6 plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests"
7     unless $ENV{LONG_TESTS};
8
9 use t::common qw( new_dbm );
10
11 diag "This test can take up to several minutes to run. Please be patient.";
12
13 use_ok( 'DBM::Deep' );
14
15 my $dbm_factory = new_dbm( type => DBM::Deep->TYPE_ARRAY );
16 while ( my $dbm_maker = $dbm_factory->() ) {
17     my $max_levels = 1000;
18
19     {
20         my $db = $dbm_maker->();
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_maker->();
33
34         my $cur_level = -1;
35         my $temp_db = $db->[0];
36         for my $k ( 0 .. $max_levels ) {
37             $cur_level = $k;
38             $temp_db = $temp_db->[$k];
39             eval { $temp_db->isa( 'DBM::Deep' ) } or last;
40         }
41         is( $cur_level, $max_levels, "We read all the way down to level $cur_level" );
42         is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" );
43     }
44 }
45 done_testing;