3 use Test::More tests => 16;
6 use t::common qw( new_fh );
10 my ($fh, $filename) = new_fh();
11 my $db = DBM::Deep->new( file => $filename, fh => $fh, );
20 isa_ok( tied(%hash), 'DBM::Deep::Hash' );
22 is( $db->{hash}{foo}, 1 );
23 cmp_deeply( $db->{hash}{bar}, noclass([ 1 .. 3 ]) );
24 cmp_deeply( $db->{hash}{baz}, noclass({ a => 42 }) );
27 is( $db->{hash}{foo}, 2 );
30 is( $db->{hash}{bar}[1], 90 );
33 is( $db->{hash}{baz}{b}, 33 );
36 1, [ 1 .. 3 ], { a => 42 },
39 $db->{array} = \@array;
40 isa_ok( tied(@array), 'DBM::Deep::Array' );
42 is( $db->{array}[0], 1 );
43 cmp_deeply( $db->{array}[1], noclass([ 1 .. 3 ]) );
44 cmp_deeply( $db->{array}[2], noclass({ a => 42 }) );
47 is( $db->{array}[0], 2 );
50 is( $db->{array}[1][2], 9 );
52 $array[2]{b} = 'floober';
53 is( $db->{array}[2]{b}, 'floober' );
55 my %hash2 = ( abc => [ 1 .. 3 ] );
58 $hash2{ def } = \%hash;
59 is( $array[3]{def}{foo}, 2 );