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