Added tests for storing tied stuff
[dbsrgits/DBM-Deep.git] / t / 31_references.t
CommitLineData
019ab3a1 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 5;
6use Test::Exception;
7use File::Temp qw( tempfile tempdir );
8use Fcntl qw( :flock );
9
10use_ok( 'DBM::Deep' );
11
12my $dir = tempdir( CLEANUP => 1 );
13my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
14flock $fh, LOCK_UN;
15my $db = DBM::Deep->new( $filename );
16
17my %hash = (
18 foo => 1,
19 bar => [ 1 .. 3 ],
20 baz => { a => 42 },
21);
22
23$db->{hash} = \%hash;
24
25is( $db->{hash}{foo}, 1 );
26is_deeply( $db->{hash}{bar}, [ 1 .. 3 ] );
27is_deeply( $db->{hash}{baz}, { a => 42 } );
28
29$hash{foo} = 2;
30is( $db->{hash}{foo}, 2 );