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