Commit | Line | Data |
867a26a0 |
1 | use strict; |
90a80a23 |
2 | use Test::More tests => 9; |
867a26a0 |
3 | use Test::Deep; |
4 | use t::common qw( new_fh ); |
5 | |
6 | use_ok( 'DBM::Deep' ); |
7 | |
8 | my ($fh, $filename) = new_fh(); |
9 | my $db = DBM::Deep->new( |
10 | file => $filename, |
11 | locking => 1, |
12 | autoflush => 1, |
13 | ); |
14 | |
90a80a23 |
15 | $db->{a} = 1; |
867a26a0 |
16 | $db->{foo} = { a => 'b' }; |
17 | my $x = $db->{foo}; |
18 | my $y = $db->{foo}; |
19 | |
90a80a23 |
20 | is( $x, $y, "The references are the same" ); |
867a26a0 |
21 | |
90a80a23 |
22 | delete $db->{foo}; |
23 | is( $x, undef ); |
24 | is( $y, undef ); |
25 | warn "$x\n"; |
26 | is( $x + 0, 0 ); |
27 | is( $y + 0, 0 ); |
3300d0b3 |
28 | is( $db->{foo}, undef ); |
90a80a23 |
29 | |
30 | # These shenanigans work to get another hashref |
31 | # into the same data location as $db->{foo} was. |
32 | $db->{foo} = {}; |
33 | delete $db->{foo}; |
34 | $db->{foo} = {}; |
35 | $db->{bar} = {}; |
36 | |
37 | is( $x, undef ); |
38 | is( $y, undef ); |