Have a 98% solution to making references work.
[dbsrgits/DBM-Deep.git] / t / 39_singletons.t
CommitLineData
867a26a0 1use strict;
90a80a23 2use Test::More tests => 9;
867a26a0 3use Test::Deep;
4use t::common qw( new_fh );
5
6use_ok( 'DBM::Deep' );
7
8my ($fh, $filename) = new_fh();
9my $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' };
17my $x = $db->{foo};
18my $y = $db->{foo};
19
90a80a23 20is( $x, $y, "The references are the same" );
867a26a0 21
90a80a23 22delete $db->{foo};
23is( $x, undef );
24is( $y, undef );
25warn "$x\n";
26is( $x + 0, 0 );
27is( $y + 0, 0 );
3300d0b3 28is( $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} = {};
33delete $db->{foo};
34$db->{foo} = {};
35$db->{bar} = {};
36
37is( $x, undef );
38is( $y, undef );