r6200@rob-kinyons-computer-2 (orig r9980): rkinyon | 2007-09-22 21:02:54 -0400
[dbsrgits/DBM-Deep.git] / t / 45_references.t
CommitLineData
1cff45d7 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 10;
6use Test::Exception;
7use t::common qw( new_fh );
8
9use_ok( 'DBM::Deep' );
10
11my ($fh, $filename) = new_fh();
12my $db = DBM::Deep->new(
13 file => $filename,
14);
15
16$db->{foo} = 5;
17$db->{bar} = $db->{foo};
18
19is( $db->{foo}, 5, "Foo is still 5" );
20is( $db->{bar}, 5, "Bar is now 5" );
21
22$db->{foo} = 6;
23
24is( $db->{foo}, 6, "Foo is now 6" );
25is( $db->{bar}, 5, "Bar is still 5" );
26
27$db->{foo} = [ 1 .. 3 ];
28$db->{bar} = $db->{foo};
29
30is( $db->{foo}[1], 2, "Foo[1] is still 2" );
31is( $db->{bar}[1], 2, "Bar[1] is now 2" );
32
33$db->{foo}[3] = 42;
34
35is( $db->{foo}[3], 42, "Foo[3] is now 42" );
36is( $db->{bar}[3], 42, "Bar[3] is also 42" );
37
38delete $db->{foo};
39is( $db->{bar}[3], 42, "After delete Foo, Bar[3] is still 42" );