5 use Test::More skip_all => "Internal references are not supported right now";
6 #use Test::More tests => 13;
7 use t::common qw( new_fh );
11 my ($fh, $filename) = new_fh();
12 my $db = DBM::Deep->new( $filename );
15 # Create structure in $db
19 subkey1 => "subvalue1",
20 subkey2 => "subvalue2",
23 subkey3 => 'subvalue3',
27 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
28 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
30 $db->{copy} = $db->{hash1};
32 is( $db->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
33 is( $db->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );
35 $db->{copy}{subkey1} = "another value";
36 is( $db->{copy}{subkey1}, 'another value', "New value is set correctly" );
37 is( $db->{hash1}{subkey1}, 'another value', "Old value is set to the new one" );
39 is( scalar(keys %{$db->{hash1}}), 2, "Start with 2 keys in the original" );
40 is( scalar(keys %{$db->{copy}}), 2, "Start with 2 keys in the copy" );
42 delete $db->{copy}{subkey2};
44 is( scalar(keys %{$db->{copy}}), 1, "Now only have 1 key in the copy" );
45 is( scalar(keys %{$db->{hash1}}), 1, "... and only 1 key in the original" );
47 $db->{copy} = $db->{hash2};
48 is( $db->{copy}{subkey3}, 'subvalue3', "After the second copy, we're still good" );
51 my ($fh2, $filename2) = new_fh();
53 my $db = DBM::Deep->new( $filename2 );
55 $db->{foo} = [ 1 .. 3 ];
56 for ( 0 .. $max_keys ) {
57 $db->{'foo' . $_} = $db->{foo};
62 my $db = DBM::Deep->new( $filename2 );
64 my $base_offset = $db->{foo}->_base_offset;
66 for ( 0 .. $max_keys ) {
68 unless ( $base_offset == $db->{'foo'.$_}->_base_offset ) {
72 is( $count, $max_keys, "We read $count keys" );