5 use Test::More tests => 16;
7 use File::Temp qw( tempfile tempdir );
8 use Fcntl qw( :flock );
10 use_ok( 'DBM::Deep' );
12 my $dir = tempdir( CLEANUP => 1 );
13 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
15 my $db = DBM::Deep->new( $filename );
24 isa_ok( tied(%hash), 'DBM::Deep::Hash' );
26 is( $db->{hash}{foo}, 1 );
27 is_deeply( $db->{hash}{bar}, [ 1 .. 3 ] );
28 is_deeply( $db->{hash}{baz}, { a => 42 } );
31 is( $db->{hash}{foo}, 2 );
34 is( $db->{hash}{bar}[1], 90 );
37 is( $db->{hash}{baz}{b}, 33 );
40 1, [ 1 .. 3 ], { a => 42 },
43 $db->{array} = \@array;
44 isa_ok( tied(@array), 'DBM::Deep::Array' );
46 is( $db->{array}[0], 1 );
47 is_deeply( $db->{array}[1], [ 1 .. 3 ] );
48 is_deeply( $db->{array}[2], { a => 42 } );
51 is( $db->{array}[0], 2 );
54 is( $db->{array}[1][2], 9 );
56 $array[2]{b} = 'floober';
57 is( $db->{array}[2]{b}, 'floober' );
59 my %hash2 = ( abc => [ 1 .. 3 ] );
61 $hash2{ def } = \%hash;
63 is( $array[3]{def}{foo}, 2 );