Commit | Line | Data |
2120a181 |
1 | use strict; |
2 | use Test::More tests => 40; |
3 | use Test::Deep; |
4 | use t::common qw( new_fh ); |
5 | |
6 | use_ok( 'DBM::Deep' ); |
7 | |
8 | my ($fh, $filename) = new_fh(); |
9 | my $db = DBM::Deep->new( |
10 | file => $filename, |
11 | locking => 1, |
12 | autoflush => 1, |
13 | ); |
14 | |
15 | for ( 1 .. 17 ) { |
16 | $db->{ $_ } = $_; |
17 | is( $db->{$_}, $_, "Addition of $_ is still $_" ); |
18 | } |
19 | |
20 | for ( 1 .. 17 ) { |
21 | is( $db->{$_}, $_, "Verification of $_ is still $_" ); |
22 | } |
23 | |
24 | my @keys = keys %$db; |
25 | cmp_ok( scalar(@keys), '==', 17, "Right number of keys returned" ); |
26 | |
27 | ok( !exists $db->{does_not_exist}, "EXISTS works on large hashes for non-existent keys" ); |
28 | is( $db->{does_not_exist}, undef, "autovivification works on large hashes" ); |
29 | ok( exists $db->{does_not_exist}, "EXISTS works on large hashes for newly-existent keys" ); |
30 | cmp_ok( scalar(keys %$db), '==', 18, "Number of keys after autovivify is correct" ); |
31 | |