2 use warnings FATAL => 'all';
6 plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests"
7 unless $ENV{LONG_TESTS};
9 use t::common qw( new_dbm );
11 diag "This test can take up to several minutes to run. Please be patient.";
13 use_ok( 'DBM::Deep' );
15 my $dbm_factory = new_dbm( type => DBM::Deep->TYPE_HASH );
16 while ( my $dbm_maker = $dbm_factory->() ) {
17 my $max_levels = 1000;
20 my $db = $dbm_maker->();
26 $db->{company}->{name} = "My Co.";
27 $db->{company}->{employees} = {};
28 $db->{company}->{employees}->{"Henry Higgins"} = {};
29 $db->{company}->{employees}->{"Henry Higgins"}->{salary} = 90000;
31 is( $db->{company}->{name}, "My Co.", "Set and retrieved a second-level value" );
32 is( $db->{company}->{employees}->{"Henry Higgins"}->{salary}, 90000, "Set and retrieved a fourth-level value" );
37 $db->{base_level} = {};
38 my $temp_db = $db->{base_level};
40 for my $k ( 0 .. $max_levels ) {
41 $temp_db->{"level$k"} = {};
42 $temp_db = $temp_db->{"level$k"};
44 $temp_db->{deepkey} = "deepvalue";
48 my $db = $dbm_maker->();
51 my $temp_db = $db->{base_level};
52 for my $k ( 0 .. $max_levels ) {
54 $temp_db = $temp_db->{"level$k"};
55 eval { $temp_db->isa( 'DBM::Deep' ) } or last;
57 is( $cur_level, $max_levels, "We read all the way down to level $cur_level" );
58 is( $temp_db->{deepkey}, "deepvalue", "And we retrieved the value at the bottom of the ocean" );