2 use warnings FATAL => 'all';
5 use t::common qw( new_dbm new_fh );
9 my $dbm_factory = new_dbm();
10 while ( my $dbm_maker = $dbm_factory->() ) {
11 my $db = $dbm_maker->();
15 subkey1 => "subvalue1",
16 subkey2 => "subvalue2",
19 subkey3 => 'subvalue3',
23 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
24 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
26 $db->{copy} = $db->{hash1};
28 is( $db->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
29 is( $db->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );
31 $db->{copy}{subkey1} = "another value";
32 is( $db->{copy}{subkey1}, 'another value', "New value is set correctly" );
33 is( $db->{hash1}{subkey1}, 'another value', "Old value is set to the new one" );
35 is( scalar(keys %{$db->{hash1}}), 2, "Start with 2 keys in the original" );
36 is( scalar(keys %{$db->{copy}}), 2, "Start with 2 keys in the copy" );
38 delete $db->{copy}{subkey2};
40 is( scalar(keys %{$db->{copy}}), 1, "Now only have 1 key in the copy" );
41 is( scalar(keys %{$db->{hash1}}), 1, "... and only 1 key in the original" );
43 $db->{copy} = $db->{hash2};
44 is( $db->{copy}{subkey3}, 'subvalue3', "After the second copy, we're still good" );
49 my $dbm_factory = new_dbm();
50 while ( my $dbm_maker = $dbm_factory->() ) {
52 my $db = $dbm_maker->();
54 $db->{foo} = [ 1 .. 3 ];
55 for ( 0 .. $max_keys ) {
56 $db->{'foo' . $_} = $db->{foo};
61 my $db = $dbm_maker->();
63 my $base_offset = $db->{foo}->_base_offset;
65 for ( 0 .. $max_keys ) {
67 unless ( $base_offset == $db->{'foo'.$_}->_base_offset ) {
71 is( $count, $max_keys, "We read $count keys" );